The most interesting aspect of Linux which makes it favorite for setting up multi user systems is the file permission and efficient user management. Because of this permissions and user management systems, it becomes almost impossible for normal users to gain root permissions or execute commands that is accessible only for root.
It is in this scenario the command sudo comes in action. Root user can define some users who can execute sets of or defined commands so that root can delegate its powers to other users. It can range from just one command to full root privileges, and in some OS, there is no real root user , just users with full root permissions. The install and configure steps are given below.
Installation
Normally sudo is bundled with the default distro, if not, we will be able to install SUDO by using the yum command
yum install sudo
Once sudo is installed (package name: sudo), you can configure it by running ‘visudo‘ as root.
Configuration
The quick and dirty way to use sudo would be to add at the end of the sudoers file :
user ALL=(ALL) ALL
where user is the name of the user.
A better usage allowing two users to have networking access in the server will be,
User_Alias NETADMINS = user1, user2
Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
NETADMINS ALL = NETWORKING
Usage
If a user have sudo permissions, he need to prefix ” sudo ” to any command he issues so that the sudo will check for the permissions, after authenticating the user by password.
examples :-
sudo ping localhost
sudo ifconfig
sudo iptables -L
If you need to get root permisssions for some time, if you have the ALL permissions, you need to use the -i flag
sudo -i
OR
sudo -s
There is much more to be learned about sudo command and its capabilities. Good way to grab more about sudo command is to start with the man pages for sudo and sudoers.