Sudo is a tool with which we can quickly execute commands as if we were another user. However, to use it, a user must have permissions to do so. Today, you will learn how to add a user to sudoers using Debian 11.
According to the sudo website:
Sudo (su “do”) allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments.
sudo is an important part of many Linux distributions and often is already installed and configured, but it is a tool that needs to be run with care.
sudo is a command that is present in most of the Linux distributions out there, some users don’t know that you have to do something before you can use it. This step is to authorize a user to use it, and this is taken care of in the
However, there are other options that can be done to achieve this goal.
How to add user to sudoers on Debian 11
The flexibility of Linux is something to be envied by other systems, so we can do this process in many ways.
But before we begin, it should be noted that on Debian
sudo is not installed by default, so the first step is to install it.
To achieve this, open a terminal or via SSH and with root privileges
apt install sudo
You can verify the version of sudo installed
Sudo version 1.8.31
Sudoers policy plugin version 1.8.31
Sudoers file grammar version 46
Sudoers I/O plugin version 1.8.31
Now you can continue.
Edit the /etc/sudoers file
As mentioned above, the
/etc/sudoers file is responsible for handling sudo users.
To edit it, the root user or another user with
sudo permissions has to run
This will open a text editor, and you will be able to edit the file in one go. To add a user, you have to place this line.
root ALL=(ALL:ALL) ALL
And below it, add your user like this
your-user ALL=(ALL:ALL) ALL
imaginelinux ALL=(ALL:ALL) ALL
Then, save your changes and close the editor
Now, the user added to
sudoers will be able to use
Add the user to the group with sudo permissions
If the user already exists, and you would rather not edit the
/etc/sudoers file, you can still make the user use sudo. To achieve this, simply add the user to a group that has
usermod -aG [Group] [Username]
In the case of Debian, Ubuntu and derivatives there is a group called
sudo in which members will have permissions to use the tool.
So to add it, you would just run for example
usermod -aG sudo imaginelinux
Remember that this command does not require root permissions.
When finished, the user will be able to use
sudo without any problems.
Sudo is an important utility for many systems and users, with it, you can quickly become a root user. However, you have to learn how to use it and above all how to manage the users that will be able to use it.
I hope you liked this post, and you can help us to share it.