Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com May 10 '12 at 15:10

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

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
share|improve this answer
add comment

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

share|improve this answer
    
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 '12 at 19:51
    
To make a complete answer for future references, I will add this point into my answer. Thanks. –  laurent May 11 '12 at 19:58
add comment

Your Answer

 
discard

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.