1 / 8

How to Add Users to Sudoers on Debian 12 Complete Tutorial

This article will explain the various methods that exist for adding users to the sudoers file so that you do not compromise on the matter of system security.<br><br>Read here:<br>https://greenwebpage.com/community/how-to-add-users-to-sudoers-on-debian-12/

Download Presentation

How to Add Users to Sudoers on Debian 12 Complete Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to Add Users to Sudoers on Debian 12: Complete Tutorial greenwebpage.com/community/how-to-add-users-to-sudoers-on-debian-12/ April 4, 2025 Tutorials by Karim Buzdar April 4, 2025 Controlling user permissions by using the sudoers file is quite an efficient way to limit the execution of commands with superuser privileges. For instance, in Debian 12, system administrators are expected to add users to the sudoers file in order to provide superuser privilege access to some specific users. For that reason, this article will explain the various methods that exist for adding users to the sudoers file so that you do not compromise on the matter of system security. Table of Contents How To Add Users to Sudoers File on Debian 12 Final Words How to Add Users to Sudoers File on Debian 12 To grant a user root privileges on their commands on a Debian 12 machine, you need to add that user to the sudoers file in the system settings. It can be accomplished in multiple ways whether you like the command line, GUI, or even via software tools. 1/8

  2. Method 1: Using the usermod Command One of the simplest methods is to add a user to the sudo group using the usermod command, thereby granting permission to execute sudo commands: Add the user to the sudo group To do so, you may replace ‘debian 12‘ with your actual username: sudo usermod -aG sudo <username> Verification You may also check the username whose group you just modified by using the groups command as follows: groups <username> Method 2: Using the visudo Command This command allows you to edit previously entered commands in sudo safely. It opens the sudoers file in the editor and then runs a check for errors before allowing a save. Add Users in Sudoers File Now, you can open the sudoers file by opening it with the visudo command: sudo visudo Find the line that has the starting word ‘root’, and you can scroll down to find it. 2/8

  3. Here is the entry corresponding to the root user. Under the root entry, add a new line following this format: <username> = <group> <command> As previously mentioned, <username> is the user that the user wants to add. <group> can be either ALL to command all to any task, or a certain group name. <command> refers to the specific commands that can be executed with sudo. If indeed all commands are to be permitted, then leave it blank. 3/8

  4. At last, save and exit the editor. Method 3: Using the useradd Command To add users to the sudoers file in the Debian 12 system, utilize the useradd command mentioned below: Creating a New User In case other users can add the user and give them sudo permission, execute the useradd command along with the new user details: sudo useradd <username> As such, the users have to change <username> with the needed username, as John: Set the user’s password Then, execute the command to set the new password for John as follows: sudo passwd <username> 4/8

  5. Grant sudo privileges Thereafter, John can reset the password associated with the account hosting the Linux system using the command ‘passwd’. Afterward, use the visudo command as explained in method 2 to give permissions to reset the password associated with the account to the user described above. Method 4: Editing the sudoers File As in any Linux Operating System, users can be added using the Sudoers file in Debian 12. Editing the sudoers file is one of the popular methods with advanced users: Open the sudoers file. Enter the terminal and use your desired text editing application (like nano) to edit the sudoers file: sudo nano /etc/sudoers The below line should be added to the file at the appropriate location: <username> ALL=(ALL:ALL) ALL 5/8

  6. Adjustments must be made to the username placeholder within the text above. Afterwards, remember to save changes and exit the editor. Method 5: Using the GUI Suppose a GUI is more appealing to you. In that case, there is a Window Interface approach in Debian to eliminate users from the sudoers file, enabling the removal of both GUI and terminal using the Debian system: Add Users in Settings Access the system settings, and progress to the “User” tab. Click on the “Unlock” option if needed. Choose “Add User,” and input the credentials of the new user: 6/8

  7. As noticed before, when the button is set to “Administrator,” this implies granting sudo access: Verification 7/8

  8. To verify the user has been correctly added to the Sudoers file in Debian 12, navigate to the following interface: That is all from the guide. Final Words To add a user to the sudoers file in Debian 12, you can add a user to the sudoers file by using the usermod command as follows: sudo usermod -aG sudo [username] will give [username] sudo privileges. Another option is using the visudo command to edit the sudoers file directly and adding [username] ALL=(ALL: ALL) ALL. Do not forget to replace [username] with the corresponding username of the account that you want to add. If you prefer a graphical method, you can go to Users in the settings of Debian and check the Administrator box for the new user. 8/8

More Related