Search results for:
Table of Contents
Tags: CentOS Web Panel
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 easiest way to create a new sudo user in CentOS 7 with sudo access. Suppose you'd like to create a normal user that does not have sudo access. Check out 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.
To create a new user with 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
usermod -aG wheel newusernamehere
Step 4: At this point, you can test the privileges of the new account by switching to the new account
su - newusernamehere
Step 5: The new user should have sudo permissions, allowing 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
sudo ls -alh /root
When 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. 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.
Written by Michael Brower / March 8, 2017