Wednesday, 20 February 2013

RHCSA: How To Grant Access To The Sudo Command

Use of the sudo command allows non-root users to make administrative changes on a system without granting them access to the root user account.

If you need to give somebody access the sudo command on a system it is necessary to make changes to the /etc/sudoers file. While in theory it is possible to use vi, nano or the editor of your choice the preferred method is to use visudo. Visudo has built in error checking to ensure that the syntax of the /etc/sudoers file is correct, otherwise you can find yourself locked out of a system and unable to make changes you need to fix it again. So make sure you use visudo.

In the /etc/sudoers file you will find a line that allows root to run all commands:

## Allow root to run any commands anywhere   
 root     ALL=(ALL)      ALL  

A quick and easy way to allow a user to run all commands is to add an additional line just below this one, like so:

## Allow root to run any commands anywhere   
 root     ALL=(ALL)      ALL 
 mugwriter     ALL=(ALL)      ALL  

This will allow the user mugwriter to use sudo to run any command. Rather than typing the root user password, mugwriter will use his own password in order to system administrative tasks.

No comments:

Post a Comment