Linux serverNETWORK ADMINISTRATIONS

How to modify sudoers file in CentOS 7

I will teach you how to modify the sudoers file to be able to run sudo commands without having to use root.

Easy way
1. Login to root using su
2. type ” usermod -aG wheel [InsertUserName] ”
3. use ” grep ‘wheel’ /etc/group ” to verify user was added
4. Once verified, type exit
5. attempt to type sudo whoami, and you should all set.

Complex way
1. Login to root using su
2. type “visudo”
3. using vim and arrow keys, navigate to line that says ” Allow root to run any commands anywhere”
4. Press the i in your keyboard to enter insert mode in vim
5. type in ” [InsertUserName] ALL=(ALL) ALL ” (exactly how it says in the root line)
6. Press esc key and type :wq to save and quit the file.
7. Once that is set, type exit to leave root, and attempt to type sudo whoami, and you should be all set.

Agustin Contreras.

source

centos 7

One thought on “How to modify sudoers file in CentOS 7

  • for some reason the / key is not working on my centos terminal, so i can't input /etc/groups in there

Comments are closed.