Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to force the user to authenticate with his password, everytime he issues a command with "sudo". However, there is one command (an init script) that I want to exclude from that need. This single command should be able to be run as sudo without the need of a password. Any idea if this is possible? Or do I need to set up a different user account for this with the only right being to call the command?

share|improve this question
add comment

2 Answers

 mirko    ALL=(ALL) ALL, NOPASSWD: /sbin/service blah start

The sudoers manpage describes this in great detail.

share|improve this answer
add comment

as sudoers manpage is too complex, needs more examples in the beggining, like a quick help...

I think this provides good restricted access:

yourUserName ALL=NOPASSWD:/usr/bin/startx -- \:1
yourUserName ALL=NOPASSWD:/usr/sbin/firestarter --start-hidden

in these above 2 examples, you prevent other commands like "firestarter --stop" what would be hazardous without password;

and "startx -- \:1" (you cant use in sudoers "startx -- :1", without "\", will fail, so this is a tip), you can bind it to a key like Super+F8 (xterm -e "/usr/bin/startx -- :1"), so if your X gets messed (like while playing a 3D game) you can hit Super+F8 and get a new X to fix it all (as on ubuntu the ctrl+alt+f1 many times give us a blank screen..)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.