How to Create and Add Sudo User on Debian?

add sudo user debian

This post may contain affiliate links/ads and I may earn a small commission when you click on the links/ads at no additional cost to you. As an Amazon Affiliate, I earn from qualifying purchases. Techsphinx also participates in the StationX Affiliate program. You can read my full disclaimer here.

This tutorial will demonstrate How to Create and Add sudo user on Debian.

Using the sudo (short for Super-user do) command, you can execute commands or run programs with the security privileges of another user (By default, the superuser – root).

After adding a sudo user, you don’t have to log in with the root account to execute administrative tasks/programs on your Debian system.

In this post, I present you with the simplest and quickest way to add sudo user on Debian.

Pre-Requisites to add sudo user on Debian

Steps to Add Sudo user on Debian

Follow these steps to create and add sudo user on Debian.

1. Log in to your Debian System

First and foremost, login to your Debian system graphically or via remote login using ssh.

ssh root@server_ip

Replace “server_ip” with the IP address of the Debian server.

2. Create a new user account

Once, logged in using the root account, create a new user for whom you want to grant sudo privileges.

If you want to give sudo access to an existing user, then skip this step and move on to step 3.

We’ll use the adduser command to create a new user.

If you get an error “adduser command not found”, then follow these steps:

1. Open the .bashrc file in the root directory.

nano ~/.bashrc

(I am using the nano text editor to open the file, you can use any command-line text editor of your choice.)

2. Add the following line to the end of the file.

export PATH=$PATH:/usr/sbin

3. Save and exit the file.

(In Nano text editor, you can use “Ctrl + x” to exit the file and when it prompts to save the file before exiting use the “y” key then hit enter.)

4. Now, either close the terminal and open it again or run the following command:

exec bash

After this, adduser command will be available.

Now create a new user using the adduser command:

adduser username

Replace “username” with your desired username.

After that, it will prompt to set a new password for the user.

Use a strong password for your user account, if you don’t want sudo privileges to fall into wrong hands.

(A strong password is a mixture of letters, numbers and special characters.)

After entering the password hit enter.

Note: You will not be able to see anything when you type the password.

Now, retype the password and hit enter.

Next, it will ask for user information, you can fill this out or just hit enter to leave it blank.

Lastly, it will ask if the information is correct, so check everything and hit “Y” and enter.

creating user to add sudo user on debian
Adduser command on Debian

A new user is added to your Debian system.

3. Add User to the Sudo group

The easiest way of granting sudo access to a user is to add the user to the sudo group. The members of the sudo group are granted sudo access.

To add the user to the sudo group run the following command.

usermod -aG sudo username

Another way of granting sudo access to a user is to edit the sudoers file. If you want to know more about this method then check out my post:

How to Add User to Sudoers file in Linux?

4. Test Sudo access on Debian

By adding the user to the sudo group, you have granted sudo access to the user. To test the sudo access for the user, login with the user account or switch to the user account using the su (switch user) command.

su - username

Now, run the sudo command followed by whoami command.

sudo whoami

Enter the password for the user and you’ll see the output of the command.



If you see root as output, that means sudo access is working properly.

Use sudo command on Debian

If you want to use any command with sudo access, just write sudo preceded by other commands.

For example, you cannot list files and folders present in the root directory without sudo access.

So, to list files under the root directory use the “ls” command with sudo:

sudo ls /root


If you want to install any package or update software repository on your Debian system, you’ll need sudo access:

sudo apt update

Once you run the command with sudo, it will ask for a password for the user account with the sudo access. This will happen only once for a session.

Enter the password to execute the command with sudo privileges.


I have shown you the easiest and quickest method to add sudo user on Debian.

Wrong use of sudo privileges can mess up your system, so use this power wisely.

As always, if you have any questions or suggestions, feel free to leave a comment.

If you like this post, then follow Techsphinx on Facebook and Twitter for more reviews, tricks, tips and tutorials.

This article needs update or correction? Report the issue here so I can update it.

Like it? Share with your friends!

Rahul R Nair

Rahul is obsessed with technology and electronic devices. He is also the founder of TechSphinx. Being a technophile, he is always busy doing some techy stuff or learning about the latest technologies. When not busy with his usual routine (staring at the computer screen) he likes to write and share his knowledge with the world.
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x