Search
Close this search box.

How to Create a Sudo User on RedHat

Table of Contents

How to Create a Sudo User on RedHat

 

Sudo is a program that runs on Unix-like computer operating systems that enable users to execute programs under the privileges provided by another user, usually the superuser. Sudo refers to either “substitute user does” or “super user does,” allowing you to temporarily elevate your user account to have root privileges. This is not the same as “us,” which has a more permanent effect.

 

Our goal here is to walk you through setting up a sudo user on RedHat,

 

Step 1: Configure the VPSie cloud server

 
  1. Sign in to your system or register a newly created one by logging in to your VPSie account. 
  2. Connect by SSH using the credentials we emailed you.
  3. Once you have logged into your RedHat instance and updating your system.

 

Check if the box needs any updates,

 

 

# sudo yum updateinfo

 

Run the command if it is available,

# sudo dnf update

 

 

Step 2: Set Up a New User Account

 

Use the adduser command to create a new user account. A user named “test user” will be made here. Add the user to the wheel group.  

 

# useradd -G wheel testuser

 

Protect your user account by adding a password.

 

# passwd testuser
Changing password for user testuser. New password: Retype new password: passwd: all authentication tokens updated successfully.

 

 

 

 

 

Step 3: Test sudo

 

 

 

 

 

Check the sudoers file with visudo.

 

# visudo

 

 

 

It’s now time to test, 

 

 

# su - testuser
Last login: Sun Dec 12 16:36:57 EST 2021 on pts/0
[testuser@LAX-110d-RedHat ~]$


That’s all for now, and I hope you’ve found this informative.

 

Cloud computing

FAQ

A sudo user is a user with administrative privileges on a Linux system who is authorized to run commands with root-level access. By default, the root user has full administrative privileges, but it is generally not recommended to use the root user for everyday tasks due to security risks.

To create a sudo user on RedHat, follow these steps:

  1. Log in to your RedHat system as the root user.
  2. Type the following command to create a new user: useradd username
  3. Set a password for the new user: passwd username
  4. Type the following command to grant the user sudo privileges: usermod -aG wheel username
  5. Save and exit the file.
  6. Log out of the root user account: exit

To test the sudo user’s privileges, follow these steps:

  1. Log in to the system as the sudo user.
  2. Type the following command to run a command with root privileges: sudo command
  3. Enter the sudo user’s password when prompted.
  4. If the command runs successfully, the sudo user has been granted root privileges.

To revoke sudo privileges for a user, follow these steps:

  1. Log in to the system as the root user.
  2. Type the following command to remove the user from the wheel group: gpasswd -d username wheel
  3. Save and exit the file.
  4. Log out of the root user account: exit

To add multiple users to the sudo group at once, follow these steps:

  1. Log in to the system as the root user.
  2. Type the following command to add the users to the wheel group: gpasswd -a username1 wheel && gpasswd -a username2 wheel && gpasswd -a username3 wheel
  3. Save and exit the file.
  4. Log out of the root user account: exit

Note: Replace “username1”, “username2”, and “username3” with the actual usernames you want to add to the sudo group.

Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Fast and Secure Cloud VPS Service

Try FREE
For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.