Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 am working with two users: me and www-data. Each user has their own group by default. I want to be able to easily grant read, write, and/or execute permissions to both users, without giving the permissions to the public.

My understanding of the Linux file permissions system is that if I have the following file:

test.php me:me 770

and the group me contains the users me and www-data, then both users would have full permissions for the file test.php. This is not working, however. I have added the user www-data to the group me and set the permissions to 770, but Apache says permissions are denied. If I change the file group to www-data so that it looks like

test.php me:www-data 770

the file loads fine. The problem is that I upload the files over ftp under the user me. It's easy to change the group, but it gets incredibly tedious if I have to SSH into the server every time I upload a new file to change the group. My understanding is that groups exist just for circumstances like these, but I don't understand why it's not working.

share|improve this question
up vote 2 down vote accepted

Change the group of all files/directories to www-data then enable setgid:

sudo chmod -R g+s /path/to/www/directory/

All files and directories will be created with www-data group from now on.

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.