CentOS: Add user into sudoer and set password free for sudo command

created at 01-25-2022 views: 3

add sudo permissions to the user

Sometimes, running the sudo command under linux will prompt something like:

xxxis not in the sudoers file. This incident will be reported.

Here, xxx is the user name, and then the sudo command cannot be executed. At this time, the solution is as follows:

Edit the /etc/sudoers file. That is, enter the command vim /etc/sudoers, enter the editing mode, and find this line:

root ALL=(ALL) ALL

add below

xxx ALL=(ALL) ALL

(where xxx is your username), then save and exit.

then ++Esc++ and type :wq! to save

Then it works.

Set sudo command to be password free

If you feel that it is troublesome to enter the password during sudo, replace the input just now with the following:

your_user_name ALL=(ALL) NOPASSWD: ALL

then ++Esc++ and type :wq! to save

now you can switch to your user account and try sudo command!

created at:01-25-2022
edited at: 01-25-2022: