Merge pull request #29601 from lkxed/20230623-0-2-Ways-to-Add-Users-to-SUDOERS-Group-in-Debian

[手动选题][tech]: 20230623.0 ️ 2 Ways to Add Users to SUDOERS Group in Debian.md
This commit is contained in:
Xingyu.Wang 2023-06-25 15:20:42 +08:00 committed by GitHub
commit aca87c60d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,109 @@
[#]: subject: "2 Ways to Add Users to SUDOERS Group in Debian"
[#]: via: "https://www.debugpoint.com/add-users-sudoers/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
2 Ways to Add Users to SUDOERS Group in Debian
======
**Heres 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][1] 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.
```
![Before adding a user to SUDOERS group][2]
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.
### 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 `Ctrl+Alt+T`.
- Switch to the root user using the following command:
```
su -
```
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.
### Another method
You can go into the root account using the same command as below. Use root account to log in:
```
su -
```
Then open the `/etc/sudoers` file using `nano` or `visudo` or any editor.
```
nano /etc/sudoers
```
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. Heres an example where you can see my username has all access.
![After granting priviledges][3]
### Closing notes
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.
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/add-users-sudoers/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed/
[1]: https://www.debian.org/releases/stable/amd64/ch06s03.en.html#user-setup-root
[2]: https://www.debugpoint.com/wp-content/uploads/2023/06/Before-adding-a-user-to-SUDOERS-group.png
[3]: https://www.debugpoint.com/wp-content/uploads/2023/06/After-granting-priviledges.png