How to Create a sudo User in Debian


Sudo (shortened for super-user do) command allows a regular user to execute a program with root privileges temporarily in UNIX or Linux operating systems. The ‘sudo command’ gives you administrative permissions to execute a program on your Linux system.

This tutorial will demonstrate you how to create a sudo user in Debian 11 bullseye distribution. Moreover, you also learn how to add a user to the sudo group and test sudo access.

Create a sudo user in Debian

Implement the following number of steps to create a new sudo user. You can also configure sudo privileges for an existing user. For an existing account, you will skip step 2.

Step 1: Log in as a Root user to your Debian system

First, log in as a root user on your system using the GUI or by using this command:

$ ssh root@server_ip_address

Replace the Ip_address with your server’s IP address.

Step 2: Create a new user

You should have the root privileges to create a new user. So now, create a new user by using this command:

$ adduser user_name

For example, we have created a new user account with the name ‘sudo_admin’ by using the above command:

$ adduser sudo_admin

This command will prompt you to enter the password and then retype to confirm it.

Important Note: it is recommended that always choose a strong password for new sudo users. For a strong password, you can include letters, numbers, and special characters.

Once you confirm the new user account password. The above command will frequently create a home directory for this new user and copies all the configuration files in the directory. Further, it prompts you to enter more information about the new user’s account. You can leave these fields blank and press Enter with the default settings.

Step 3: Add user to sudo group

All sudo group members of the ‘sudo’ group are granted sudo access on Debian systems. By using the ‘usermod’ command, you can easily add an existing or a new user to a sudo group.

$ usermod -aG sudo username

Below, we have added the newly created user ‘sudo_admin’ into a sudo group.

$ usermod -aG sudo sudo_admin

Verify sudo access

Now, use the ‘su’ command to log in as a sudo user.

$ su - sudo_admin

Once you log in as a sudo user. Execute any command with sudo privileges. For example, here we have executed the ‘whoami’ command. If you have sudo privileges, it will return ‘root’ in the output:

$ sudo whoami

How to use the sudo command?

To use the sudo command, use the sudo and use space. After that, enter the desired command.

$ sudo visudo

You need to enter the password for the first time to start a sudo session.


We demonstrated in this article how to create a sudo user in Debian 11. Moreover, we explained how to add a user to a sudo group.

Similar Posts