Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to grant a particular user sudo access for one particular command only?

Thanks

--

More info:

We farm out lengthy optimisation runs to each other's boxes over ssh. These runs take hours, sometimes days.

The shutdown command can only be run in sudo. Being conscious of my environmental footprint, I would like to give the initiator(s) of these runs sudo access to the shutdown command on my box, without sudo access for everything else - so that they may shutdown my machine when they no longer need it.

I am aware that I can schedule a shutdown before I leave my box, but I am looking for a better solution.

share|improve this question
    
Can we assume you haven't looked at the docs? – Ignacio Vazquez-Abrams Dec 22 '10 at 5:41
    
@Ignacio Vazquez-Abrams : which docs are you referring to? – bguiz Jan 4 '11 at 0:09
1  
The sudoers(5) man page. – Ignacio Vazquez-Abrams Jan 4 '11 at 0:50
    
Consider accepting the (seemingly correct) answer, or comment on what doesn't work for you. – Daniel Beck May 15 '11 at 14:57

use

visudo

as root, and add

%admin ALL = NOPASSWD: /sbin/shutdown

to the end of the file, then

  • add the user to admin group

and you can run "sudo shutdown -h now" from the user.

or rather, chmod 4755 the shutdown command.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .