Create a User with Sudo Permission on RHEL / CentOS
On RHEL / CentOS server, the wheel group is granted with sudo. We can give sudo access to an existing user too. In this topic, we’re going to learn how to create a user and give permission to the user.
Table of Contents
Create a New User
To create a user, we need to use the
useradd command like this:
Set User Password
To set user’s password, we need to run the
You’ll see the output like:
Changing password for user theusername. New password: Retype new password: passwd: all authentication tokens updated successfully.
Provide Sudo Permission
We need to add the user to the
usermod -aG wheel theusername
The user theusername has sudo permission now.
Test Sudo User
First, we need to switch to the newly created sudo user:
su - theusername
Now let’s run a sudo command:
# stucture sudo [anycommand] # example sudo php -v
The first time, you’ll be asked to provide the user’s password.
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 theusername:
The article is over. Thanks for reading. ?