How to Add a User to Root Group and Grant Privileges on Ubuntu 16.04

Posted on by Alison Gray | Updated:
Reading Time: 3 minutes

Ubuntu 16.04 LTS provides you the ability to add a user for anyone who plans on accessing your server.  Creating a user is a basic setup but an important and critical one for your server security. In this tutorial, we will create a Linux user and grant administrative access, known as root, to your trusted user. Learn how to add a user to root group and grant privileges on Ubuntu 16.04

How to Add a User and Grant Root Privileges on Ubuntu 16.04

Preflight Check

  1. We will need to open a terminal and log in as the root user.
  2. We will be working as that root user on a Linux Ubuntu 16.04 LTS server

Creating a Linux User with Root Privileges

Step 1:  Add The User

Create a username for your new user, in my example my new user is Tom:

adduser tom

You’ll then be prompted to enter a password for this user.   We recommend using a strong password because malicious bots are programmed to guess simple passwords. If you need a secure password, this third-party password generator can assist with creating one.

Output:

~# adduser tom
 Adding user `tom' ...
 Adding new group `tom' (1002) ...
 Adding new user `tom' (1002) with group `tom' ...
 Creating home directory `/home/tom' ...
 Copying files from `/etc/skel' ...
 Enter new UNIX password:
 Retype new UNIX password:
 passwd: password updated successfully
Note
Usernames should be lowercase and avoid special characters. If you receive the error below, alter the username. ~# adduser Tom adduser: Please enter a username matching the regular expression configured via the NAME_REGEX[_SYSTEM] configuration variable.  Use the `--force-badname' option to relax this check or reconfigure NAME_REGEX.

Next, a text prompt will appear asking us to enter in info about your new user.  Entering this information is subjective and is not required. This info can be skipped if needed by pressing enter in each field. We suggest adding in as much info as needed to track usage.

Enter the new value or press ENTER for the default
 Full Name []:
 Room Number []:
 Work Phone []:
 Home Phone []:
 Other []:

Lastly, the system will ask you to review the information for accuracy.  Enter Y to continue to our next step.

Is the information correct? [Y/n]

Step 2: Grant Root Privileges

Assigning root access to a user is to grant the user the highest privilege on our system so caution is advised.  Once out user Tom is added, he can make changes to the entire system as a whole, so it's critical to only allow this access to users who need it. After this, Tom will be able to execute commands using the sudo option which is normally reserved for the root user.

usermod -aG sudo tom

Step 3: Verify New User

As root, you can switch to your new user with the su - command and then test to see if your new user has root privileges.

su - tom

If the user has properly been granted root access the command below will show tom in the list.

grep '^sudo' /etc/group

Output:

sudo:x:27:tom

That's it! We have added a user to root group a and then granted that Linux user corresponding root privileges on an Ubuntu 16.04 LTS server.

Get Started Today!

Would you like to learn more about setting up a new Ubuntu server? Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions or Experienced Hosting advisors to learn how you can take advantage of these techniques right away!

Avatar for Alison Gray

About the Author: Alison Gray

Alison Gray is currently an IT Project Manager at Liquid Web and has been with Liquid Web for nearly 10 years. In 2015, She earned her Bachelor's Degree in Media and Information from Michigan State University. In her free time, she loves spending time with her girlfriend and 3 kids. You can usually find her at a basketball court or some sort of sporting event. If the weather's right, she loves being outside in the yard finding some sort of yard work to do.

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article