Here’s how you can add users to the SUDOERS group in Debian Linux.
In Debian Linux, the SUDOERS group plays a crucial role in granting administrative privileges to users. Adding users to the SUDOERS group enables them to execute commands with root privileges, providing them with the necessary administrative access to perform various tasks on a Debian system.
During the installation of Debian Linux, if you keep the password for “root” account empty, the first user created in the system will have the administrative rights. However, if you do set the “root” password, then the user names will not have the sudo privileges. Hence, you might get a similar error below when using the user account to perform administrative tasks.
<username> is not in the sudoers file. This incident will be reported.
This article aims to provide a step-by-step guide on adding a user to the SUDOERS group in Debian, ensuring that you can effectively manage user permissions and system security.
Table of Contents
How to Add User to SUDOERS Group in Debian
To add a user to the SUDOERS group in Debian, follow these simple steps:
- Open the terminal on your Debian system by clicking on the “Terminal” icon or by using the shortcut
- Switch to the root user using the following command:
You will be prompted to provide the root password. Enter the root password and press enter.
After you log in as the root user, enter the following command. Make sure to change as per your username. For this example, replace “arindam” with your user name.
/sbin/addgroup arindam sudo
If the above command says invalid, you can also use the following command:
usermod -aG sudo arindam
Press exit to leave the root prompt. Log out and log in again. Now you can perform any administrative action using your username.
You can go into the root account using the same command as below. Use root account to log in:
Then open the
/etc/sudoers file using
visudo or any editor.
Add the following lines with the username. Change “arindam” as per your user name.
arindam ALL=(ALL) ALL
Save and close the file. And then, log out and log in again. And that should give the user name the root privileges.
Verifying SUDOERS Group Membership
To verify that the user has been successfully added to the SUDOERS group, you can open a new terminal window and enter the following command. Replace “username” with the actual username of the user you added to the SUDOERS group.
sudo -l -U arindam
If the user is a member of the SUDOERS group, you will see the list of privileges they have. Here’s an example where you can see my username has all access.
Adding a user to the SUDOERS group grants them significant administrative privileges. It is important to carefully consider the trustworthiness and responsibilities of the user before giving them such access. Improper use of sudo can lead to accidental damage or compromise of the system.
Remember to exercise caution when delegating administrative privileges and regularly review user permissions to maintain a secure Debian system.