Skip to main content

Add user to sudo

You most likely already have sudo installed (should be installed by default in Debian 11). Because of that, the sudo group already exists and is in /etc/sudoers file. The only thing we have to do is add our user to the sudo group.

1. Login as root

2. Add user username to sudo group

(root)$ usermod -aG sudo username
  • -a adds user to a new supplementary group
  • -G specifies the name of the group to append to the user

3. Check whether your user is in the sudo group

(root)$ groups username
username : username cdrom floppy sudo audio dip video plugdev netdev bluetooth lpadmin scanner

As you can see from the output, sudo is on of the groups username is in.

4. Log out of root, login as your user and try to use sudo do execute a privileged command like apt upgrade. You will be prompted for a password (your user password, not root password). If you type it in correctly, and the command works, you have appropriate privileges, if not, you will be warned that the user isn't in the sudoers file.