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've edited the /etc/sudoers file through visudo and added

www-data        ALL=(git)       NOPASSWD: ALL
git             ALL=(www-data)  NOPASSWD: ALL

so now the user "git" should be able to execute commands as "www-data", but when I try to

sudo -u git ls /tmp/redmine_git_hosting

I get:

ls: cannot open directory /tmp/redmine_git_hosting/: Permission denied

The permissions of directory are:

drwx------  2 www-data www-data 4096 Jan 31 09:02 redmine_git_hosting

I can list directory by running:

sudo -u www-data ls /tmp/redmine_git_hosting
share|improve this question
As you can see. Owner has rwx permissions while group has no permissions at all. You need to add git in the www-data group and change directory permissions of redmine_git_hosting to drwx-rw--- so git could read and write. – val0x00ff Jan 31 '13 at 7:49
@val0x00ff: That doesn't work either. – Iain Jan 31 '13 at 7:52
up vote 1 down vote accepted

I think you've misunserstood how sudo works. What it does is let the user git use sudo to run commands as the user www-data - but in order to do that, the user git has to run sudo, it's not enough that you become the user without using sudo from that user.

In short, you'd need to do something like

 sudo -u git sudo -u www-data ls /tmp/redmine_git_hosting 


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.