How To Create a Sudo User on Ubuntu

Here is how you can create a sudo user on Ubuntu. In particular on Vultr’s instance i.e. Ubuntu 16.04 LTS / 18.04 LTS / 18.10 / 22.04 LTS.


  • Have an Ubuntu 16.04 x64 / 18.04 x64 / 18.10 x64 / 22.04 X64 instance.
  • Logged in as a root with sudo privileges.

To get started with the creation of a new user, follow the steps below:

Logging Into Your Server via Secure Shell (SSH)

SSH into your server as the root user:

ssh root@your_server_ip_address

Create a Sudo User on Ubuntu

Create a new user account with the adduser command and use a strong password.

adduser mohsin

and the output will be

Adding user `mohsin' ...
Adding new group `mohsin' (1001) ...
Adding new user `mohsin' (1001) with group `mohsin' ...
Creating home directory `/home/mohsin' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

After that, you will be asked to enter values for the user information e.g. Full Name, Room Number etc, or press ENTER to leave those fields blank.

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

Add the User to the Sudo Group

Use the following command to add the user to the sudo group:

adduser mohsin sudo

and the output will be

Adding user `mohsin' to group `sudo' ...
Adding user mohsin to group sudo

Test Sudo Access

Now switch to the new user with the following command

su - mohsin

Verify with the following command:


and the output will be:


Now test sudo access with sudo whoami, which should return root.

sudo whoami

and the output will be

[sudo] password for mohsin:

After giving the password, output will be


Note: Be sure to replace mohsin with the username you just added.


Now you have learned how to create a new user with sudo access on Ubuntu. If you have questions feel free to leave a comment below.

Ubuntu 16.04Ubuntu 18.04Ubuntu 18.10Ubuntu 22.04