Home > Article > Operation and Maintenance > 2 ways to add users to SUDOERS group in Debian
The SUDOERS group plays a vital role in Debian Linux, granting administrative rights 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 Debian systems.
During the installation of Debian Linux, if you leave the password of the root
account blank, then the first user created in the system will have the administrative permissions. However, if you set a root
password, the username will not have sudo permissions. Therefore, you may encounter errors similar to the following while using the user account to perform administrative tasks.
<username> is not in the sudoers file. This incident will be reported.
Before adding users to the SUDOERS group
This article aims to provide a step-by-step guide on adding users to the SUDOERS group in Debian to ensure that you can Effectively manage user permissions and system security.
To add a user to the SUDOERS group in Debian, follow these simple steps:
Ctrl Alt T
to open the terminal on the Debian system. su -
You will be prompted for the root password. Enter the root password and press Enter.
After logging in as the root user, enter the following command. Make sure to change it according to your username. In this example, replace arindam
with your username.
/sbin/addgroup arindam sudo
If the above command does not work, you can also use the following command:
usermod -aG sudo arindam
Press Exit to leave the root prompt. Log out and log back in. Now you can perform any administrative operations using your username.
You can use the same command as below to get into the root account. Log in with root account:
su -
Then use nano
or visudo
or any editor to open the /etc/sudoers
file.
nano /etc/sudoers
Add the following lines and username. Replace arindam
with your username.
arindamALL=(ALL)ALL
Save and close the file. Then, log out and log back in. This should give the username root access.
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 arindam
with the actual username of the user you added to the SUDOERS group.
sudo -l -U arindam
When a user belongs to the SUDOERS group, you can view their permission list. Here is an example, you can see my username has all access rights.
After Granting Permissions
Adding users to the SUDOERS group will grant them important administrative rights. Careful consideration of the user's trustworthiness and responsibility is critical before providing such access to the user. Improper use of sudo can cause unexpected damage or damage to your system.
Remember to use caution when delegating administrative rights and regularly check user permissions to maintain a secure Debian system.
The above is the detailed content of 2 ways to add users to SUDOERS group in Debian. For more information, please follow other related articles on the PHP Chinese website!