On this short article, we will learn how to add an regular user to be sudoers on CentOS 7 opearting system.
Sometimes we need root level privileges to run some tasks in an operating system, in this case CentOS 7. For this purpose, the operating system has provided a facility known as sudo. The sudo command stands for “Super User DO” and temporarily level up the privileges of a regular user for administrative tasks. In this article, we will discuss how to add a regular user to sudoers.
CentOS 7 system
Root user or regular user who already has sudo privileges
Adding New User To sudo Group
CentOS 7 has a user group called the “wheel” group, where the members of this group are automatically granted sudo privileges. We will add a new user to this group to grant sudo privileges to that user. For this purpose we will do the following tasks.
Verify the ‘wheel’ group is enabled
For the first time, we have to verify if the wheel group is enabled. For this purpose we will submit the following command line:
We will be entering to /etc/sudoers file, then find and remove the ‘remarks sign’ on the left side.
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
to be :
%wheel ALL=(ALL) ALL
Add New User to wheel Group
To add a new user to wheel group, we will submit the command line :
$ usermod –aG wheel UserName
Adding New User To Sudoers Configuration File
To ensure, a new user having sudo privilege, we have to add to sudoers configuration file.
Submit $ visudo command line.
Add new user to sudoers configuration file
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
ramansah ALL=(ALL) ALL
On this tutorial, we will add a new user called as ‘ramansah’ to the file.
Testing sudo Privilege
After all are set, then we will test a new user to do the root account can do.