How To Create a New Sudo-enabled User on Ubuntu 20.04

By | February 28, 2022

While managing a server, you will sometimes want to execute commands as “root”. Best practice is to create a user and to promote it as a part of SUDO group.
This way, your newly created user shall able to perform task, which is only allowed for administrators.

Step 1: Log into your server

$ ssh root@your_linux_ip_address

Step 2: Adding a new user to the System

# adduser imran

Here user “imran” is used as an example. You can have your own username

Next, you’ll be asked to fill in some information about the new user. You can accept the defaults and leave this information blank:

Output
Changing the user information for sammy
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: Adding a new user to the sudo group

# usermod -aG sudo imran

Step 4: Testing new user sudo access

To test this newly added sudo permissions are working or not, you can run the following command.

# su – imran

Hope this will help as a quick start for creating new users.