Unlike many others Linux operating systems, Debian does not really configure Sudo for the user during installation. But, if you are using a Debian based operating system. Such as Bunsen Labs, Devuan, SolydXK or any other, you also may not have Sudo configured. If so, please follow this guide as the instructions should be similar, just as these operating systems are based on Debian. In this article, we are going to talk about How to add a user to Sudoers on Debian. Let’s get started!
The easiest way to get Sudo access for a user on Debian is to simply ignore adding users to the Sudoers file through the group management tools altogether and instead manually edit the Sudoer file, specifying a user. specific and granting it all permissions.
To start adding a single user to the Sudoers file on Debian, simply open a terminal window. When the terminal window is open, you will need to log into the Root account. The reason? The root account is required to modify system files, including sudoers.
When your terminal window is open, you can also access the root account on Debian by running the know command in a terminal. Remember that you will also need to remember the root password set during the Debian installation process.
After logging into the root account in the terminal of your Debian PC, you will need to open the Sudoers file for editing. The Sudoers file is located in the
/etc/ directory (
/etc/sudoers) also. But, you should never edit the file directly. Instead, you should use the visudo order.
Note: In this guide, we also use the Nano editor because it is accessible and easy to use for most Linux users. If you don’t really like Nano, feel free to change “Nano” in the command below to something else as well.
When the visudo command has been executed, the Nano editor will then open the Sudoers file on your Debian Linux PC. From there you can use the Down Arrow to locate the particular line “
## User privilege specification“.
Now under that line you should see “
root ALL=(ALL) ALL. ”This code tells Debian that the Root account can use Sudo. You will need to reproduce this line for your own use in order to provide it with Sudoer privileges.
In the Nano editor, under “
root ALL=(ALL) ALL”Create a new line, then write in the line below. Keep in mind that you will have to change “user” to your username to access Sudo in Debian.
When you have written the line for the Nano text editor, the Sudoers file should be saved. To save it in Nano, press the Ctrl + O combination of keys on the keyboard. Click on Ctrl + X to leave.
Debian add user to sudoers – add via sudo group
On Debian, if you don’t want to add users individually, the operating system also allows users to give any user account Sudo access just by adding them to the file. sudo group. Here is how you can do it.
First, open a terminal window if you don’t already have one open. On Debian, the easiest way to open the terminal window is to press Ctrl + Alt + T on the keyboard. When the terminal window is open, then you must log in to the root account via the know order.
Now that the terminal session is logged into the root account, you will need to run the grep command to determine if the “South” exists on your Debian Linux PC.
grep -i "sudo" /etc/group
The output should display “
sudo“ and also indicates that your Debian Linux PC does have the sudo group. If for some reason your Debian Linux system doesn’t really have the sudo group as it should. Then you can also create it using the following command in a terminal window.
After creating the new group, rerun the grep command to confirm its presence.
grep -i "sudo" /etc/group
Whenever you have confirmed that the sudo group is there, you can use the usermod -aG command to add existing users to the group. By adding users to this group, they will be able to run sudo commands on Debian.
Note: Make sure to run the user mod command below as many times as necessary to give users access to sudo.
usermod -aG sudo YOUR_USERNAME
Do you need to remove a user from the sudo group in order to deny them sudo privileges? You can remove any user from the sudo group by running the user mod -G command below in a terminal window.
su usermod -G sudo YOUR_USERNAME
After removing the user from the group, he will no longer be able to run sudo commands in Debian.
Okay, that was all folks! I hope you enjoy this article and that it is useful to you as well. Give us your opinion on it. Also, if you have other questions and issues related to this article. So let us know in the comments section below. We will get back to you shortly.
Have a nice day!