How to Add a User to Sudoers in Debian

In Debian, to give a user sudo privileges, what you need to do is add the user to the sudo Linux group.

user is not in the sudoers file

You can add a user to the sudo group by using the usermod command:

usermod -aG sudo user_name
  • Replace user_name with the name of the user you want to add to the sudoers.
  • Make sure to use the correct options: -a and capital G.
  • The -a option appends the sudo group to the user's existing groups without removing the user from other groups.

The usermod command also needs root privileges. So you have to either log in to your root account or use another account that already has sudo privileges.

After running the command, make sure to restart the computer. After the restart, log in as the user and run the groups command to confirm the user is in the sudo group.

groups
add user to sudoers on debian

Once the user is added to the sudo group, they can run sudo commands without getting the user is not in the sudoers file error.