How to Create Sudo User on Ubuntu

Sudo is a Linux Command.Sudo means “superuser do”. It allows authenticated users to run commands as other users. Other users can be ordinary users or super users. In this tutorial, you are going to learn how to create sudo user on Ubuntu.


Before you start to create sudo user on Ubuntu. You must have the root user of your system.

Create a sudo User

first,log in to your system or ssh your server as a root user.

ssh [email protected]_ip_address

Now, create  a new user account using the adduser command. Don’t forget to replace new_username with the user name that you want to create:

useradd new_username

Here you will be prompted to enter the password for the user you want to create and confirm it. Enter a strong password for the new user you are creating:

New password:
Retype new password:
passwd: password updated successfully

After setting the password, it will create the HOME directory for the user saving some configuration files. Then it will ask you some more information about that user.If you want to leave all of this information blank just press ENTER to accept the defaults.

Changing the user information for username
Enter the new value, or press ENTER for the default
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]

By default on Ubuntu systems, members of the group sudo are granted with sudo access. To add the user you created to the sudo group use the usermod command:

usermod -aG sudo new_username

Test the sudo user access

Now you switch to new account using su command to do so run below command:

su - new_username

Then,use the sudo command to run the whoami command:

sudo whoami

If the user have sudo access then you will get below output:


How to use sudo

For example,you can use sudo to display contents of root directory:

sudo ls -la /root

The first time you use sudo in a terminal session, you will be prompted to enter the user password:

[sudo] password for username:

You have learned how to create a user with sudo privileges. You can now log in to your Ubuntu server with this user account and use sudo to run administrative commands.

If you have any queries regarding this then please don’t forget to comment below.

Leave a Reply