Read in 2 minutes
How To Create a Sudo User on CentOS
sudo command is designed to allow users to run programs with the security privileges of another user, by default the root user. In this guide we will show you how to create a new user with sudo privileges on CentOS.
How to create a sudo user
By default on CentOS, users in the group wheel are granted with sudo access. Follow this steps to create a sudo user on your CentOS server. If you want to configure sudo for an existing user, skip to step 4.
Log in to you CentOS server as the root user:
ssh [email protected]_ip_address
Create a new user account using the
usernamewith the user name that you want to create.
passwdcommand to set a password for the new user:
Changing password for user username. New password: Retype new password: passwd: all authentication tokens updated successfully.
Add the new user to the wheel group.
usermod -aG wheel username
How to use sudo
Switch to the newly created user:
su - username
To use sudo, simply prefix the command with
sudo and a space.
sudo ls -l /root
The first time you use sudo from this account, you will see the following banner message and you will be prompted to enter the password for the user account.
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:
That’s all. You have successfully created a sudo user on your CentOS system. You can now use this user to perform administrative tasks on your server.
Feel free to leave a comment if you have any questions.