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

What is the best way to grant sudo privileges to a user only for the /opt/myapp directory as if the user were root in CentOS?

The idea is to allow developers to do whatever they want only on the /opt/myapp directory but to avoid for example that they remove some important directory or shutdown the server.

share|improve this question

migrated from Jan 31 '13 at 16:17

This question came from our site for professional and enthusiast programmers.

If you merely want a user to have full read/write/execute permission on /opt/myapp, then set the permissions that way. If you want something else, you will need to clarify. – William Pursell Jan 31 '13 at 13:59
Perhaps the solution is to give each of them (or the whole bunch) a virtual machine? – vonbrand Jan 31 '13 at 19:11

Perhaps, you could use chroot environment

share|improve this answer
Please don't just provide links for your answers. What happens when that page is moved/deleted? – Lee Taylor Feb 25 '13 at 15:31

There are two really simple ways of doing this:

1) If you want everyone to see it you can change the permissions (chmod 421 /opt/myapp) where 4 is read 2 is write and 1 is execute

2) If you want only one person to view it you can change the owner of the file (chown newOner /opt/myapp)

Both of these will most likely require root

share|improve this answer

First, define (within /etc/sudoers) a Cmnd_Alias for the commands you want the user to be able to run: Cmnd_Alias MYAPPS = /opt/myapp/some_executable, /opt/myapp/another_one Then create a user rule that allows them to run them some_user ALL = MYAPPS

share|improve this answer

You must log in to answer this question.