How to Install Sudo and Create a Debian 10 Sudo User

Depending on how you installed Debian 10 Buster, sudo may not have been installed by default. This is normal, actually. So first you have to install it and for that, you need to have access to the root user of the system. This is vital!

The last thing you want is to be logged into your Debian server as the root user. Don’t do it. This is the very reason why sudo was created -to prevent administrators from logging in as root and find themselves possibly vulnerable to attacks. Install sudo, add users to that group, and forget about that root user, unless absolutely necessary. This is an important step in securing your Debian server.

You can install sudo from the Debian repositories.

apt update
apt upgrade
apt install sudo


Creating a Debian sudo user involves a few simple steps. Before you can add a user to your system, log in as the root user.

  1. Add a new user in Debian

sudo adduser username

2. Add user to the sudo group

sudo usermod -aG sudo username

usermod is the tool that modifies a user account.

-aG is the option that tells the command to add the user to a specific group. The -a option adds a user to the group without removing it from current groups. The -G option states the group where to add the user. In this case, these two options always go together.

sudo is the group we append to the above options. In this case, it is sudo, but it can be any other group.

username is the name of the user account you want to add to the sudo group.

To verify the new Debian sudo user was added to the group, run the command

getent group sudo

The output will lists all users in the group

3. Switch to the newly created user

su - username

You can now log in to your Debian server with this user account and use sudo to run administrative commands


Stay in the Loop

Get the weekly email from TechLifeTravel that makes reading the news actually enjoyable. Join our mailing list to stay in the loop to stay informed, for free.