On CentOS, you get the very vibe of the corporate and server workspace where not all the users are allowed to have access to everywhere in the system. The only user with TRUE power is the “root” user holding the admin privilege to even manipulate data on the hardware-level!
For other users, they have to contact the “root” user to perform the tasks that require elevated privilege. In most of the Linux distros, you have the “sudo” command that allows that certain command to be run as an admin task.
However, on CentOS, even if you know the password of the “root” account, you still can’t perform “sudo” commands. CentOS protects the sudo access to only known users.
Today, we’ll be having a look at adding a user on the “Sudoers” list, essentially enabling the access to the “sudo” command.
Performing this action should only be allowed when it’s necessary. Otherwise, the system admin should do the job personally. If you’re a system admin, make sure that you understand what you’re about to do.
If the user account was created before, then don’t follow the following steps. In this section, we’ll be checking on adding a new user in the system.
At first, enter the “root” mode –
Now, add a user in the system –
Time to add a password for the user –
Adding a user to the “sudoers”
Run the following command as the “root” –
usermod -aG wheel <username>
This command will add the specific user into the “wheel” group. By default, the users in this group will automatically have the access to the “sudo” command.
Switch to the new user –
su - <username>
Now, run any command using “sudo” –
Voila! Everything is working properly!