Before we see how to add user to sudoers in Debian 10, lets briefly understand how sudo privilege works. When you use a Linux system, you are logged in with a user which has it’s own session. On a high level, activities which you can perform are limited, you are not allowed to use files for which you don’t have permissions, can’t install applications for other users etc.

When you are root user, or have root privilege, you have basically the system administrator privilege. There is no limitations to what you can do.

While installing Debian, you are asked to set up a root password and a user account. When you login to your system next time, you login to the user account and not with root.

In other Linux distributions, say Ubuntu, you can execute any command with root privilege by feeding in the root password. However, Debian don’t allow this by default. You either have to switch completely to the root user or add user to sudoers list in Debian 10.

It’s not an ideal scenario where you need to switch back and forth between the user and root, hence the need to list the user in sudoers file. Another problem is when its a multi-user system, you most certainly don’t want to share the root password to anyone.

Do you know you can update Debian 10 offline?

By adding a user to sudoers list, you basically give them the privilege to run administrative command.

Before we begin, lets verify if you are in sudoers list.

group

If the output doesn’t have sudo, you are not in the list. If you try to install any application using sudo, you will get an error saying –

<user> is not in the sudoers file. This incident will be reported.

add user to sudoers in Debian 10

Add user to sudoers in Debian 10

To add a user to sudoers, you must first be the root. Open a terminal and login to root by typing below command.

su -

You can see the root shell now.

ambarish@debian:~$ su -
Password:
root@debian:~#

To add the user, type in below command

sudo adduser ambarish sudo

adduser command adds user ‘ambarish’ to the group ‘sudo’.

root@debian:~# sudo adduser ambarish sudo
Adding user ambarish to group sudo
Adding user ambarish to group sudo
Done.

Exit from the terminal. To reflect the changes, you will need to reboot your Debian system.

Once done, you can check whether the user is part of sudo groups now. Open terminal and use groups command to check again

Group - add user to sudoers in Debian 10

You can see sudo in the list now.

Wrapping Up

Granting administrative privilege can be fatal in a big set up. If it’s a personal laptop, you can go ahead and do it. However granting administrative privilege can be fatal in the corporate world (e.g. a server with multiple users).

Make sure you understand the concept before you do it. If you face any issues, let us know in the comments.