How to Add a User and Grant Root Privileges on CentOS 7

Posted on by Justin Palmer | Updated:
Reading Time: < 1 minute
Users via Command Line 101: Basic User Interaction
I. How to Add a User and Grant Root Privileges on CentOS 7
II. How to Remove (Delete) a User on CentOS 7
Preflight Check
  • These instructions are intended specifically for adding a user on CentOS 7.
  • I’ll be working from a Liquid Web Self Managed CentOS 7 server, and I’ll be logged in as root.

How to Add a User and Grant Root Privileges on CentOS 7

Step 1: Add the User

It’s just one simple command to add a user. In this case, we’re adding a user called mynewuser :

adduser mynewuser

Now set the password for the new user:

passwd mynewuser

Step 2: Grant Root Privileges to the User

For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor

visudo

Find the following code:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL

In this case, we’re granting root privileges to the user mynewuser . Add the following below that code:

mynewuser ALL=(ALL) ALL

Then exit and save the file with the command :wq.

If you’ve followed the instruction above correctly, then you should now have a user setup by the name of mynewuser which can use sudo to run commands as root!

Avatar for Justin Palmer

About the Author: Justin Palmer

Justin Palmer is a professional application developer with Liquid Web

Latest Articles

Blocking IP or whitelisting IP addresses with UFW

Read Article

CentOS Linux 7 end of life migrations

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article