Home » Tutorial » How To Create a Sudo User on Ubuntu Operating System

How To Create a Sudo User on Ubuntu Operating System

Update on:
Mar 2, 2020

We talk about “sudo” privileges, we are talking about the “sudo” command.

The “sudo” command allows users to run any other commands, services, or program with the privileges of another user, and by default, it took the privileges of the root user.

In this tutorial, we will learn how to create a new user with sudo access on Ubuntu Operating System. So, you can use this user to execute an administrative command in the system without login as root user in your Ubuntu machine.

Create a Sudo User

We will create a new user in Ubuntu machine with sudo privileges in simple three steps. If you want to give sudo privileges to an existing user, you can directly go to step 3.

Step 1: Log in to your server

In the first step, you need to login into your system or server with root user, using the following command:

$ ssh [email protected]_ip_address

Step 2: Create a new user account

Now, we will create a new user in this Ubuntu machine by using ‘adduser” command. Please replace the “user_name” with the user name that you want to create:

$ adduser username

Your screen will be prompted to set the password for your new user. Make sure the password of a new user is to follow the secure password guidelines.

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

Once a password is get configured for a new user, the command will create a home directory for the new user. It will copy several files in the home directory and ask you to set new user’s information. If you want to leave all of these information blanks just press “ENTER” and accept configured default values.

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]

Step 3: Add new user to sudo group

In the Ubuntu system if you get a member of the sudo group you will get the sudo access. To add a user into the “sudo” group, use the following usermod command:

$ usermod -aG sudo username

Test the sudo access

To check you have sudo access or not, first go to your account login. To this either you login using your username and password or switch to your account using “su” command, as shown below:

$ su - username

Now, run “whoami” command with sudo:

$ sudo whoami

If the user having sudo access, you will get the output of the “whoami” command is “root”:


How to use sudo

To use the sudo privileges with any command is very simple, prefix the command with “sudo” and space as shown below:

$ sudo ls -l /root

In a session, first-time use of “sudo”, you will get a screen to enter the user password:

[sudo] password for username:


You have learned how to create a new user in Ubuntu System and assign the sudo access or privileges to a user in Ubuntu machine. Now, you can log in into your Ubuntu system or server with your user access and use “sudo” command to run administrative commands.

Feel free to leave a comment if you have any doubt or questions.

Related Posts

How to Install CouchDB on Ubuntu 21.04 Linux Operating System

How to Install CouchDB on Ubuntu 21.04 Linux Operating System

The CouchDB is an open-source database system, managed by the Apache Software Foundation. It is fault-tolerant, and schema-free NoSQL database management system.   CouchDB store data in document or files with JSON data structure. Each document contains fields and...

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

How to Install Nginx on Ubuntu 21.04 Server

How to Install Nginx on Ubuntu 21.04 Server

Nginx is the most potent, open-source, and a high-performance Web server. It can work as a reverse proxy server also, nowadays, is used by most of the most significant websites on the internet. People pronounced “engine x” for Nginx; it is the hot choice for every...

How to Install VirtualBox on Ubuntu 21.04 Linux

How to Install VirtualBox on Ubuntu 21.04 Linux

VirtualBox is an Open Source tool, known as a cross-platform virtualization application or software. It used to run multiple operating systems or virtual machines simultaneously on a single hardware. In this VirtualBox installation tutorial, we will explain the...

Follow Us

Our Communities

More on Ubuntu

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!



Submit a Comment

Your email address will not be published.

4 × 1 =