Creating a sudo user on centos

Creating a sudo user on centos

To execute admin actions using regular user, you need to create a sudo privilaged account. By default in CentOS, any user part of wheel group is granted access to execute privilaged commands. Follow below steps to create 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 new password twice. Go ahead and enter new password of your choice. Below is the output:

[root@ ~]# 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 below step.

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

Thats it! Now you can login with your preferred user and use sudo in the beginning of any command and you should be able to execute any commands that requires admin access.