2 ways to add users to SUDOERS group in Debian

PHPz
Release: 2023-07-05 19:13:45
forward
2435 people have browsed it

在 Debian 中将用户添加到 SUDOERS 组的 2 种方法

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.
Copy after login

在 Debian 中将用户添加到 SUDOERS 组的 2 种方法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.

How to add a user to the SUDOERS group in Debian

To add a user to the SUDOERS group in Debian, follow these simple steps:

  • Single Click the "Terminal" icon or use the shortcut key Ctrl Alt T to open the terminal on the Debian system.
  • Switch to the root user using the following command:
su -
Copy after login
Copy after login

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
Copy after login

If the above command does not work, you can also use the following command:

usermod -aG sudo arindam
Copy after login

Press Exit to leave the root prompt. Log out and log back in. Now you can perform any administrative operations using your username.

Another method

You can use the same command as below to get into the root account. Log in with root account:

su -
Copy after login
Copy after login

Then use nano or visudo or any editor to open the /etc/sudoers file.

nano /etc/sudoers
Copy after login

Add the following lines and username. Replace arindam with your username.

arindamALL=(ALL)ALL
Copy after login

Save and close the file. Then, log out and log back in. This should give the username root access.

Verify 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 arindam with the actual username of the user you added to the SUDOERS group.

sudo -l -U arindam
Copy after login

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.

在 Debian 中将用户添加到 SUDOERS 组的 2 种方法After Granting Permissions

Conclusion

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!

Related labels:
source:51cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template