As all we know most of the administrative commands are found under /sbin directory in linux, which a normal user wouldn't have access to. In the following example, I'm going to show you how we delegate control to a normal user to run commands that are located under /sbin directory.
First login as root
# vim /etc/sudoers
Under the command Allow root to execute any command any where type the following
nagoor ALL = /sbin/fdisk, /sbin/ifconfig, /sbin/runlevel
(Specify like this to allow nagoor user to allow only fdisk, ifconfig and runlevel commands)
nagoor ALL = (root) /sbin/
(Specify like this to allow nagoor user to allow any commands that are under /sbin directory)
(Use any one of the above to see proper results, after saving and come out of the file, login as the user nagoor to verify)
# su - nagoor
# sudo /sbin/fdisk -l
(Command will prompt to enter password for nagoor user, then after specifying the password the output will be displayed on the standard output)
First login as root
# vim /etc/sudoers
Under the command Allow root to execute any command any where type the following
nagoor ALL = /sbin/fdisk, /sbin/ifconfig, /sbin/runlevel
(Specify like this to allow nagoor user to allow only fdisk, ifconfig and runlevel commands)
nagoor ALL = (root) /sbin/
(Specify like this to allow nagoor user to allow any commands that are under /sbin directory)
(Use any one of the above to see proper results, after saving and come out of the file, login as the user nagoor to verify)
# su - nagoor
# sudo /sbin/fdisk -l
(Command will prompt to enter password for nagoor user, then after specifying the password the output will be displayed on the standard output)
No comments:
Post a Comment