6

I have a directory foo with drwxr-x--- someuser somegroup and some files created in that directory foo that have read permissions for the owner, group and other. How can I give user otheruser write permissions to that directory without adding this user to somegroup?

Is it possible to use setfacl for this?

Thanks.

0

2 Answers 2

4

For actual files and new files you need to set acl with:

setfacl -Rm d:u:otheruser:rwX,u:otheruser:rwX /your/dir

use X (uppercase) if you want only directories to be x and not files. Use x (lowercase) to include files.

The d:u:otheruser part is for default (new files) and the 2nd part of the command is for existent files. You can set different permissions on each part if you prefer.

-R is for recursive

Thanks to user390689 (original asker) input, mask (and default mask) needs to be added too because setfacl should (according to man setfacl and my own experience) create one based on the union of the existing groups acls and the added permissions. As in this case you are supplying only user and no groups, there is no acl for the groups and the union is empty so you need to do it manually with:

setfacl -Rm d:m:otheruser:rwX,m:otheruser:rwX /your/dir
1

Thanks. I also discovered I needed to set mask first with setfacl -m m:otheruser:rwX.

2
  • 1
    True. I almost never have to use the mask entry but I mostly use acl and regular permissions with groups and not single users. If no mask entry (or default mask) is given and a named user or group is supplied, setfacl should (according to man setfacl and my own experience) create one based on the union of the existing groups acls and the added permissions. As you are supplying only user and not groups, there is no acl for the groups and the union is empty so you need to do it manually.
    – laurent
    May 11, 2012 at 19:51
  • To make a complete answer for future references, I will add this point into my answer. Thanks.
    – laurent
    May 11, 2012 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .