How to create Sudo users in CentOS 7

How to create Sudo users in CentOS 7

Introduction

Sudo is the abbreviation of Super User Do. It is a command that enables programs to be implemented as a root user. Sudo runs commands provided to it with the privileges of a root user. It helps system administrators to grant specific users the permission to effectuate commands at the most powerful level (root level) without the need to log into the system as the root users. This tutorial will help you create a unique user account in your CentOS system and grant it sudo privileges. It’ll also help you get started with sudo Ready? Let’s get started!

Step 1 –
Creating A New Sudo User

To create another  user in your CentOS  system, first run the command below to log into your server as a root user:

# ssh root@server_ip_address

Once you log in, execute the command below to create the new user:

# adduser hostadvice

The value hostadvice represents the name of the user you are about to create. Remember to replace this value with your desired username. Next, execute the command below to set up the password for your newly created user:

# passwd hostadvice

This will give you a new output and you will be required to enter and retype the password for your new user. Make sure you have a strong password that combines letters, characters, and numbers.

Changing password for user username.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Once you set up the password for this user, you can now execute the command below to add it to the CentOS wheel group.

# usermod -aG wheel username

By default, all users in the CentOS wheel group are given sudo access. For this reason, when you add the new user to the CentOS wheel group, you will automatically grant it sudo privileges.

Step 2 –
Using Sudo in CentOS

By now, you have successfully created a new user and granted it sudo access. Next, you should grasp the basics to utilize sudo on CentOS with ease. First, run the command below to  switch to your newly generated user:

$ su - hostadvice

Next, to utilize sudo you should prefix every command line with the sudo, followed by space. Run the command below to put the new user account to its first use:

$ sudo ls -l /root

Since this is the first instance you are using sudo on CentOS, you will get an output with the following message;

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for username:

Enter the password created in step one to continue. This will take you to the prompt of the newly created user. This prompt will be similar to:

[hostadvice@centos-s-1vcpu-1gb-tor1-01]$

If you want to execute any command as the root user, simply type exit and press ENTER, to exit the sudo account.

Conclusion

Congratulations! You have flawlessly created a new user and granted it sudo permissions on a CentOS server. If you want to create multiple sudo users on your Linux hosting (specifically, a VPS or dedicated server) follow all the steps for each user. Remember to give a unique username and password for each user.

Check out these top 3 Linux hosting services

Webdock
AU$1.39 /mo
Starting price
Visit Webdock
Rating based on expert review
  • User Friendly
    3.8
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.3
  • Pricing
    4.3
Kamatera
AU$5.87 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Ultahost
AU$3.67 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8
  • To know further about best VPS hosting, click here.
 

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Install MongoDB on Your CentOS 7 VPS or Dedicated Server

MongoDB is designed for extensive databases and is mainly used for data analytic
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Set Up a Linux VPN Server from a Windows Client

VPN is important for securely connecting to server’s resource
less than a minute
Vladimir Rakov
Vladimir Rakov
Hosting Expert

How to Set Up SSH on a CentOS 7 VPS from a Windows Client

Download puttygen into the Windows machine as shown in figure 1. Then sta
less than a minute
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top