Creating a sudo user on centos

A man working on a laptop with code on it.

To execute admin actions using a regular user, you need to create a sudo privileged account. By default, in CentOS, any user part of a wheel group is granted access to execute privileged commands. Follow the below steps to create a sudo account.

  1. Login to your CentOS machine as root.
ssh root@IP_Address
  1. Create new user.
adduser johnsmith

NOTE: you can replace johnsmith with your preferred username.

  1. Create password for johnsmith user.
passwd johnsmith

You will be promoted to type a new password twice. Go ahead and enter a new password of your choice. Below is the output:

Output:

[root@10.10.10.10 ~]# passwd johnsmith
Changing password for user johnsmith.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Now after a user and password has been created. We need to add johnsmith user to wheel group. Follow the below steps.

  1. Add user to wheel group.
usermod -aG wheel johnsmith

That’s it! Now you can log in with your preferred user and use sudo at the beginning of any command, and you should be able to execute any commands that require admin access.

Leave a Comment

Scroll to Top