How To Add a User and Grant Root Privileges on Ubuntu 16.04 / 18.04

Adding a user and granting that user root privileges is one of the many tasks of a system admin.   Once a user has been added and granted root privileges they’ll be able to login to your Ubuntu 16.04 / Ubuntu 18.04 and perform vital functions for the upkeep of the system. Afterward, they’ll be able to use sudo before commands to perform elevated tasks.  In this quick tutorial, we’ll show you how to add a new user and grant root permissions.

Pre flight

  • These instructions are intended specifically for adding a user on Ubuntu 16.04 / Ubuntu 18.04 LTS.
  • We’ll be working from a Liquid Web Core Managed Ubuntu 16.04 / Ubuntu 18.04 LTS server, and I’ll be logged in as root.

Step 1: Add the Username

In my example, I’ll be adding my cat’s name, Tom, using the adduser command. Replace tom with your desired username. During this time, the system will also ask of me details from my user.  Feel free to skip these details by pressing enter and eventually it asks us to confirm that the info is correct, leading us to a new user added.

adduser ubuntu

Example Output:
Adding user `ubuntu' ...
Adding new group `ubuntu' (1001) ...
Adding new user `ubuntu' (1001) with group `ubuntu' ...
Creating home directory `/home/ubuntu' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for ubuntu
Enter the new value, or press ENTER for the default
Full Name []: Ubuntu
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

Step 2: Grant Root Privileges to the User

visudo

The command below leads us to the /etc/sudoers.tmp file where we can view the following code:# User privilege specification
root    ALL=(ALL:ALL) ALL

After the root user line, you’ll add in your new user with the same format for us to grant admin privledges.

ubuntu ALL=(ALL:ALL)ALL

Once you’ve added the permission, save and exit the file by using :wq and enter.

Step 3: Verify User Has Priviledges

If you’ve followed the instructions correctly then this user will be able to run commands like, update, using the sudo:

su - ubuntu

sudo apt-get update

Want to do admin tasks through a control panel? Check out our servers that come with cPanel servers. or you can choose our Shared Hosting which comes with cpanel. We offer free migrations and 24/7 support making it effortless to switch to BDWEB IT!