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:
useradd theusername
Set User Password
To set user’s password, we need to run the passwd
command:
passwd theusername
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 wheel
group:
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. ?
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)