Oct 12, 2023 3 min read

How to Create a Sudo User on CentOS

Create sudo user on CentOS with our step-by-step tutorial. The command helps user to run programs with security factors of another user.

Create a Sudo User on CentOS
Table of Contents


Before we begin talking about how to create a Sudo User on CentOS, let’s briefly understand - What is a Sudo User?

The sudo command helps users to run programs with the security privileges of another user, which is a root user by default. You can even perform administrative tasks on your CentOS machine without a need to log in as the root user with the help of sudo.

Creating a sudo user on CentOS allows you to grant administrative privileges to a user account, enabling them to perform system-level tasks.

In this tutorial, you will create a Sudo user on CentOS. We will also address FAQs related to Sudo user.

Creating Sudo User  

Sudo's access is granted to users in the group wheel by default on CentOS. For configuring a sudo user, you need to add your user to the wheel group.

Step 1 - Login to the Server

1) Log in to the CentOS server through ssh as the root user:

ssh root@server_ip_address

Step 2 - Create a new user account

1) After that, use the useradd command to create a new user.

useradd username

Make sure to replace username with your desired username.

Step 3 - Set the User Password

1) After that, use the passwd command to set a password for the new user.

passwd username

2) Confirm the password when you'll be prompted to. Ensure that the password is a strong one.


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

Step 4 - Add a New User to the Sudo Group

1) Sudo access is granted to users in the group wheel on CentOS. Then, add the new user to the wheel group:

usermod -aG wheel username

How to use Sudo

You now need to switch to the user you have created.

su - username

Prefix the command with sudo and a space to use sudo.

sudo [COMMAND]

You can list the contents of the /root directory with the following command:

sudo ls -l /root

You shall come across the following message when you use sudo for the first time from this account. You will have to enter the password as well:


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:

FAQs to Create a Sudo User on CentOS

Why should one use Sudo?

The sudo command allows an individual to run programs with the security privileges of another user (as mentioned earlier).

Can I revoke sudo privileges from a sudo user? 

Yes, you can revoke sudo privileges from a sudo user by removing their entry from the sudoers file or modifying their permissions.

How do I prevent unauthorized users from becoming sudo users? 

By default, only users with administrative access can create sudo users. It is crucial to protect administrative accounts and restrict account creation privileges.

Is it possible to set password policies for sudo users? 

Yes, you can enforce password policies for sudo users by setting password complexity requirements and expiration rules in the CentOS system.

Can I limit the time period during which a sudo user has administrative privileges? 

Yes, using the "sudoers" file, you can configure time restrictions for sudo user privileges, ensuring they only have administrative access for specific periods.

Can I create a sudo user without a password prompt? 

It is not recommended to create a sudo user without a password prompt for security reasons. Password prompts help prevent unauthorized access.

Are there any alternatives to using the sudo command? 

While the sudo command is commonly used, alternatives like "su" (switch user) or "pkexec" (policy kit) can also provide elevated privileges.


Creating a sudo user on CentOS brings several advantages, including enhanced security, better accountability, granular privilege control, simplified administration, and improved system stability.

It allows you to delegate administrative tasks to trusted users while reducing the risk of unauthorized access or unintended changes.

By following the tutorial and best practices for managing sudo users, you can effectively maintain control over your CentOS system and ensure a more secure and efficient administration process.

If you have any queries, please leave a comment below and, we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.