Server Fault is a question and answer site for system and network administrators. 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

I would like a user to have sudo rights (without password check) to a couple of shell scripts under a specific directory (in my case, /usr/local/tomcat7/bin), and to nowhere else. What's the simplest way to accomplish this?

Something like this in /etc/sudoers didn't seem to work:

jsmith ALL=(ALL) NOPASSWD: /usr/local/tomcat7/bin
share|improve this question
up vote 14 down vote accepted

I think you are almost there. put a / at the end of your directory spec

jsmith ALL=(ALL) NOPASSWD: /usr/local/tomcat7/bin/

From the sudoers man page

A directory is a fully qualified path name ending in a '/'. When you specify a directory in a Cmnd_List, the user will be able to run any file within that directory (but not in any subdirectories therein).

share|improve this answer
Thanks (to both answerers), got it working! Note to self: need to invoke the scripts directly (e.g. sudo stop) - this doesn't work: sudo sh stop. – Jonik Jul 27 '11 at 17:17

Add a slash '/' to the end of the path.

jsmith ALL=(ALL) NOPASSWD: /usr/local/tomcat7/bin/
share|improve this answer

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.