I need to give permission for two users in the same directory, ie

I'm running a web application in /var/www and I want to make web server(nginx) writable, also want to give access to a ftp user(/var/www is the home directory of ftp user). I have tried with setfacl but that doesn't work?

  • What OS are you running on? setfacl has some problems on Ubuntu – Dylan Jan 20 '15 at 0:55
  1. (optionally) create a group groupadd groupname
  2. add both users to the group for u in user1 user2 ; do usermod -aG groupname $u ; done
  3. set the group as the owner of the directory (and files inside) chown :groupname /var/www ; chmod -R g+rwX /var/www

acl should work. Are you using it right? Giving recursive rule for existing files and default for new files?

sudo setfacl -Rm d:g:<user-group>:rwX,g:<user-group>:rwX /var/www

Will give your main group rw permissions on files and x on the directories (to enter them).

-R: recursive
-m: modify existing rule (used to modify the existing permissions)
d:g:...:rwX: this indicates the default part for new files/directories
g:..:rwX: group to use for the acl
rwX: read, write and change directory allowed (rwx will allow execute on files too)

The command has two parts: d:g:..... before the , and g:.... after the , The 1st one (d:...) will assign the default for new files/directories and the 2nd one (g:...) will modify existing files.

Obs: you can also use acl for users (with u:) or other (o:) instead of groups (g:)

  • It worked for me but only when I removed d: – Wizard79 Aug 19 '17 at 19:29

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.