Privileged commands without sudo


Motive: Bring out some specific commands like shutdown, restart from sudo restriction.
Example: #sudo reboot to #reboot


For changing this, we need to edit /etc/sudoers.tmp file for that we need to run the following command on the terminal[Applications->Accessories->Terminal].


#sudo visudo


A file will open in your default text editor [nano is my default]



Then add user list just after the line says: '# User alias specification', like this:


User_Alias USERS = thecoderin,ubutrix,user3


And add those commands for avoid sudo prefix just after '# Cmnd alias specification', like this:


Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/reboot, /sbin/halt


Then We need to give the permissions to the USERS to run SHUTDOWN_CMDS without sudo and passwords. Goto end after the %admin line put this line


USERS ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS



MORE DETAILS


MANual page for visudo [link]
MANual page for sudoers [link]


nJoY!

0 comments:

Post a Comment