I have a folder (/var/www/test7.com), which must be readable/writable by www-data AND test7 users.

test7 user should not have access to other websites.

How can I do that?

  • 1
    Can't you put both users in a new group? – htorque Apr 10 '11 at 18:06
  • I've posted an answer below, but a solution not involving group tricks would be symlinks within the test7.com directory to locations owned by www-data. That would prevent users from messing with webserver files. – ImaginaryRobots Apr 10 '11 at 18:12

Create a group, put both users in this group and type:

chown -R GROUPNAME /var/www/test7.com/*

I hope this helped you, Daniel


The simplest way would be to add the www-data user to the test7 group, and have the files owned by test7, not www-data.


most confusing way would be to use 'acl' (apt-get install acl) tool to create advanced control lists, where you can allow/disallow access to files using advanced rules.

for example, you have directory owned by root and 3 other users, using acl you can set that direcotry owner is still root with 700 rights, but then set acl that will allow one user to read files, and other 2 read/write files in the directory.

All of that can be done using setfacl (to set up permissions) getfacl (to read permissions). Directories can have default settings what to assign to files/folders.

If not used with care you can mess up permissions pretty good.

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.