CentOS also comes up with a similar policy. It only allows a certain users to perform actions with the “root” privilege. For example, whenever you run any command with the “sudo” command, you’ll get the following error –
For fixing the issue, the user account must be in the “sudoers” file. In this tutorial, we’ll check out on adding a user into the “sudoers” file.
Adding users to the “sudoers”
The trick here is NOT directly editing the “/etc/sudoers”
file. Instead, we’ll be adding the specific user into the “wheel” group. In the case of CentOS, all the users in the group have the ability of running “sudo” commands and that’s the easier and safer way.
This is also proven within the “/etc/sudoers”
file –
Optional – creating a new user
I’m going to create a new user for the “sudo” purpose only. Don’t worry; you can easily add the existing user.
Enter the “root” mode –
Now, create a new user –
Time to add a password for the newly created username –
It’s finally time to add the user “Yasuo” on the “wheel” group. At first, make sure that you’re logged as the “root” –
Now, perform the final action –
Everything is set!
Testing the outcome
Well, it’s always worth testing the outcome, no matter how obvious it may seem. Let’s try out running a “sudo” command as “Yasuo” –
Voila! “Yasuo” is now a privileged user account capable of “sudo”!