I'm running Arch Linux.

My website's files are in /home/user/www/ directory. Another users also have their website's files in /home/foo/www/ directories.

Now if I want to change something on their webistes I must have sudo access.

I want to access their directories without sudo.

How can I set the directory to user and me, and chown it to 755 for others (apache)?

  • I think you're misunderstanding how permissions work, you don't chown to "755 for others", 755 is overall permissions. You need to look into setting up groups and granting permissions in that way. – Chris Davidson Jan 4 '15 at 21:05

You can use Access Control Lists (ACLs) for this, giving additional permissions to a specific user for a particular file or directory.

First off, make sure that the filesystem in question has the acl option enabled: commonly it will by default, but you can add it to the options in fstab (and/or remount).

With ACLs enabled you control the ACL on a particular file or directory using the setfacl command:

setfacl -m "user:vonflynee:rwx" /home/foo/www

That sets a per-user permission for user vonflynee of rwx (formatted as in chmod) for that particular directory, in addition to the permissions the owner of the file already has. You can have multiple ACL specifications for a particular file for different users and groups that you need to deal with, and they can have any combination of different permissions.

As with other permissions, you need to be able to traverse the whole tree up to the file you want to access, so you may need to set others further up the tree, and you'll need access to the files too. setfacl supports a --recursive mode to set permissions on a whole tree.

The Arch wiki has a moderately comprehensive article on the subject with Arch-specific parts of the process highlighted.

Another option, and the more conventional one, is simply to make a new group "vonflyneeandfoo", add both users to it, chown -R the directory to that group, chmod g+s the directory so that new files inherit its group, and then chmod -R g+rX dir to give the files group write permission.

If there's only this single case you need to deal with this is likely to be the simpler option. Even if it is, if you have many local users and you're relying on apache being a group member already then making the read permissions work out is harder and ACLs will be more convenient for you.

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.