Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I know how to create a command which a given user can execute via sudo. I have a given command I want to allow any user to be able to execute via sudo without entering a password. What would I put in my /etc/sudoers file in order to make that happen?

share|improve this question
up vote 13 down vote accepted

A section like this in your sudoers is probably what you want.

Cmnd_Alias NAMEOFTHIS=/usr/bin/program
share|improve this answer
Doesn't that grant access just to user username? Is there a wildcard I can use instead? I want any authenticated user to be able to execute the command. – Josh Sep 23 '10 at 19:07
Then use a group they are all members of. – Broam Sep 23 '10 at 19:10
Thanks! I swear I tried that but I forgot a space, so it wasn't working! – Josh Sep 23 '10 at 19:10
If it's not all users, I'd add a group simply because this is membership of something you wish to track - who can sudo this way. – Broam Sep 27 '10 at 15:45
If you really don't want to add a group (beats me why not) and still need individual users, use User_Alias SOMEUSERS = user1, user2. – Brett Ryan Aug 2 '12 at 5:37

You might consider the SUID bit. Certain programs require root privileges and use the SUID bit, such as passwd.

If sudo is the better choice for you, you could use:

ALL ALL=NOPASSWD: /path/to/command
share|improve this answer
It's a shell script which restarts a local caching nameserver... so SUID won't work in this case, right? – Josh Sep 23 '10 at 19:05
Zoredache beat me in the time it took for me to test my recommended solution. =) – Warner Sep 23 '10 at 19:12
While he was simultaneously harassing me in chat for posting such an easy question, no less! – Josh Sep 23 '10 at 19:17
@Josh:then don't post easy questions :-) – Bart Silverstrim Sep 24 '10 at 13:25
@Josh: Sounds like a neat feature, actually. Multiharassitasking. – Bart Silverstrim Sep 24 '10 at 13:44

Your Answer


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.