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.

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.