How to Add User to Sudoers in Debian 12

Sudoers is the file in Linux distributions including Debian and Ubuntu, which manage the users who can enjoy the root privileges. The operating system’s administrative tasks can be managed and controlled by super users.

Other than the root users or super users, these root privileges can be utilized by the other users with the sudo command.  

The sudo command can be used by the other users only if these users are in the sudoers file. In this post, we will walk through the methods of adding the users in the “sudoers” file in Debian 12. 

What is the “vboxuser is not in the sudoers file”  error?

This error comes on the screen if the user is now allowed to run the superuser command. For example, when updating the packages, the following error appeared on the screen:

$ sudo apt update

This error can be removed by adding the users to the sudoers file in Debian by the methods explained in the next section. 

What are the Methods of Adding the Users to Sudoers in Debian 12?

The different users can be added to the sudoers file in Debian 12 by either of the mentioned methods:

  1. Using the usermod command
  2. Using the visudo command
  3. Using the GUI

Before moving to the explanation of these methods, log in to the root user terminal by using the command:

$ su

Method 1: Add a User to Sudoers Using the usermod in Debian 12

To add the users in sudoers using the usermod command, simply follow the below steps. 

Step 1: Add the User to the Sudo Group

First, add the user to the group of sudo by replacing the “username” with the actual username in the below command:

# sudo usermod -aG sudo [username]

For example, the user “vboxuser” is added to the sudo group following the above command:

# sudo usermod -aG sudo vboxuser

Step 2: Verify the Addition of the User to sudo Group

To verify the successful execution of the above command, list the groups in which “vboxuser” is a part:

# groups vboxuser

Method 2: Add a User to Sudoers Using the visudo command in Debian 12

Another method of adding the users in the sudoers file is by using the visudo command. To do so, run the commands explained in below steps. 

Step 1: Utilizing the visudo, Modify sudoers File

Open the sudoers file with the visudo text editor to edit it:

# sudo visudo

Step 2: Add the User to the sudoers File

Now add the user to the sudoers file by replacing the “username” with the actual user. For example, to add the “vboxuser” in the sudoers file, run the command:

# vboxuser ALL=(ALL:ALL) ALL

Close the file by saving the changes in the sudoers file. And also exit the root terminal with the command:

# exit

Method 3: Add a User to the sudoers File in Debian 12 Using the GUI

The GUI (Graphical User Interface) is the convenient method of adding a new user in the sudoers file. Open the settings of Debian 12 and navigate to the “Users” option:

Then click on the “Unlock..” option:

Click on the “Add User”:

Now toggle the button of the “Administrator” after entering the new user credentials:

By doing so, the user will be added to the sudoers file automatically with its creation. 

How to Test the sudo Command?

To make sure that the user is in the sudoers file, update the packages of Debian 12:

$ sudo apt update

The successful execution of the update command confirms the addition of the user in the sudoers file. 

How to Remove the User from sudoers in Debian 12?

To remove the user from the sudoers file in Debian 12, run the below-mentioned command by replacing the “vboxuser” with your username:

$ sudo deluser vboxuser sudo

The user has been removed from the sudoers file in Debian 12. 


To add the users in the sudoers file, by replacing the username, run “sudo usermod -aG sudo [username]” the command in the terminal. One can also add the user by opening the sudoers file with the text editor and adding the line “[username] ALL=(ALL:ALL) ALL”, then saving the file. This blog has a step-by-step explanation of both of the methods stated.