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 have a user who is getting this problem:

Sorry, user myuser is not allowed to execute '/bin/cp /tmp/tempfile /applications/tomcat/instance/webapps/' as tomcat on

When running the following command:

sudo -u tomcat cp /tmp/tempfile /applications/tomcat/instance/webapps/

What change should I make (I assume with visudo) to allow the user to execute /bin/cp as the tomcat user? The user is a member of the tomcat group.

Thanks in advance


share|improve this question
up vote 4 down vote accepted
myuser        ALL = (tomcat) /bin/cp

is about as simple as it gets. you can allow all members of the tomcat group to do it by putting

%tomcat       ALL = (tomcat) /bin/cp

That ALL there refers to the host in question; if you use this sudoers file on more than one host, it would be inappropriate, but if this sudoers file is particular to this host, it's safe enough and avoids issues with what the machine thinks its hostname is.

share|improve this answer

What are the rights and owner in /tmp/tempfile file ? You should have the right to modify a non by me created file (due to /tmp restrictions)

share|improve this answer
Forgive me, Dom, but I think you may be misreading the question. Even if sudo was letting him run the command, the file in /tmp/ is the source file of the copy, not the destination; the destination's in /applications/tomcat, and it seems sensible to me that only tomcat can write into that. – MadHatter Oct 26 '10 at 15:00
Right, I re-read the question two times, and my answer is bad. Thanks to point it. – Dom Oct 27 '10 at 6:47

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.