How to give two user permission in same directory (linux)

2

1

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?

John

Posted 2014-09-25T10:30:14.193

Reputation: 21

What OS are you running on? setfacl has some problems on Ubuntu – Dylan – 2015-01-20T00:55:29.940

Answers

4

  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

Jon Story

Posted 2014-09-25T10:30:14.193

Reputation: 319

2

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:)

laurent

Posted 2014-09-25T10:30:14.193

Reputation: 4 166

It worked for me but only when I removed d: – Wizard79 – 2017-08-19T19:29:09.060