2 Ways to add users to sudoers group in Debian 11

Set up sudoers users in Debian 11 using this tutorial: The “Sudoers” is a file in which the rights of the users are managed. For example, the system administrator (root) can assign another user root rights.

The additional user with sudo rights  can then:

  • Execute commands with root rights
  • View files that only users with root privileges can open (e.g. the / etc / shadow file)
  • In the same way, the system administrator can revoke the rights of the user by removing the user from the Sudoers file.


Debian 11 Linux: Add an existing user to the sudo group

#Ist method:

After installing Debian, the /etc/sudoers file must be edited first, otherwise commands with root rights cannot be executed. However, for that, you must first switch to the root user. The following command-line command adds an existing user to an existing group.

First Switch to root user

The below command allows you to switch to the root user. When it asks for the password enter the one you have set for your Debian 11 root user.

su root

Add an existing user to the Debian 11 sudo group

Now, I am assuming that you already have a user on your Debian system that you want to add to the sudo group for running commands under root rights. If yes, then follow the below command.

usermod -aG {Group} {Username}
  • sudo = Work with root rights
  • usermod = changes a user account
  • -aG = –append (adds the user to further groups), G = –groups (groups)


sudo usermod -aG sudo rajm

Change the rajm in the above command with your system user that you want to add in the sudo group.


Furthermore, if you don’t have any other user apart from root or you want to add a new user then run:

adduser username

The above command will allow you to add a new user. Note: Replace username with the name that you want to give your new user.


#2nd way

If the above method didn’t work for you then directly edit the Sudoers file to add the user in it. For that use the below commands:

Switch to the root user, if you already have not.

su root

Edit Sudoers file on Debian 11

Now, edit the sudoers file using the given command.

nano /etc/sudoers

Add your User

Scroll down to the end of the file and add the following line.

username ALL=(ALL:ALL) ALL

Note: Replace the username with the user that you want to add to the sudo group in Debian 11 Bullseye.

For example, here our username is rajm, thus the above command will be like this:


add users to sudoers group in Debian 11


Save the file by pressing Ctrl + O and exit the file by using Ctrl +X keys.

That’s it, now you can run your existing user with sudo rights on Debian 11 Bullseye or 10 Buster.



Comments (2)

  1. Brad September 15, 2021
  2. Auridian February 19, 2022

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.