Create a sudo user (CentOS 7)

In some cases when you execute commands on your server, or computer, they need to be executed with root privileges. However, you may not have access to the root account itself or you may have that type of access limited on your server for security reasons. This is where the “sudo” command comes in to save the day! By using the sudo command you can temporarily grant or escalate root level privileges to a normal user. This article will teach you the absolute easiest way to create a new sudo user in CentOS 7 that has sudo access. If you’d just like to create a normal user that does not have sudo access, checkout our article: How To Create A New User (CentOS 7). Please be aware that you’ll need to access your server using SSH. If you’re not certain how to access your server via SSH, please refer to the following guide: Connecting To Your Server Via SSH

 

How To Create A User With Sudo Access In CentOS 7

To create a new user that has sudo access, you’ll need to have access to the root account, however this is only for the initial creation process. Once you have access to the server using the root account, please move on to the following procedure.

 

Step 1:  Issue the adduser command to add a new user to your server

 

 

 

Step 2:  Change the password for the new user

 

 

 

Step 3:  Add the new user to the wheel group using the usermod command

 

 

 

Step 4:  At this point you can test the new accounts privileges by switching to the new account

 

 

 

Step 5:  The new user should have sudo permissions which should allow you to execute any command with the word sudo prefixed before the command for example you can list the contents of the root directory like so

 

 

 

The first time that you use sudo in a session, you’ll be prompted for the password to complete the command. If you followed this guide and the password was entered correctly, you should now see the directory listing for the root user. Having and using a sudo user is an excellent security practice, as it ensures that you can still enjoy the benefits of having the root user’s privileges without some of the risks associated with using the root account all of the time.

 

Related Articles


Share:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.