How to create a sudo user in CentOS

Sudo users are those users who can execute sudo command. Sudo command grants temporary administrator privileges like authority to install programs, modify system settings and system files.

As these can modify the system settings and cause harm to the system, these privileges are only reserved for the root users. But by using sudo other users can also enjoy this authority. That’s why it’s important to allow only trusted users to be sudo user.

Steps to Create a New Sudo User on CentOS

Step 1: Login into CentOS as the root user

ssh root@server_ip_address

Here replace server_ip_address with the network IP address of your server. Then enter your credentials when prompted.

Step 2: Add a new user to your system

# adduser username

Here remember to replace username with the username you want to have for your new account. (For example, we are creating an account by username lotoftech.)

Step 3: Set a password for the new account

# passwd username

Here again, replace username with the username of your account. You will not see anything while typing the password. Retype the password to make confirmation.

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

Step 4: Add the new user to the sudo group

# usermod -aG wheel username

On CentOS systems, users of wheel group are granted sudo access by default. Hence here we are adding the new user to the wheel group.

This creates a new sudo user in CentOS. Now let’s verify if the newly created sudo user account works.

Verify new sudo user account works

su - username

This command will switch the user account to the new user account created.

username$ sudo command

Run above command while replacing command with whatever you would like to try. You will be asked to enter user account password enter that and you should see command work.

Conclusion:

Here we saw how to create a sudo user in CentOS. We hope you it worked for you. If you face any problem or something is not working for you do tell us in comments.

If you are using a Linux system you know how important a good text editor is. That’s why here are the best text editors for Linux you can try using.

Leave a Reply

Share via
Copy link
Powered by Social Snap