How do I set up a shared directory on Linux?
- by JR Lawhorne
I have a linux server I want to use to share files between users in my company. Users will access the machine with sftp or secure shell.
Here is what I have:
cd /home
ls -l
drwxrwsr-x 5 userA staff 4096 Jul 22 15:00 shared
(other listings omitted)
I want all users in the staff group to be able to create, modify, delete any file and/or directory in the shared folder. I don't want anyone else to have access to the folder at all.
I have:
Added the users to the staff group by modifying /etc/group and running grpconv to update /etc/gshadow
Run chown -R userA.staff /home/shared
Run chmod -R 2775 /home/shared
Now, users in the staff group can create new files but they aren't allowed to open the existing files in the directory for edit. I suspect this is due to the primary group id associated with each user which is still set to be the group created when the user was created. So, the PGID of user 'userA' is 'userA'.
I'd rather not change the primary group of the users to 'staff' if I can help it but if it is the easiest option, I would consider it.
And, a variation on a theme, I'd like to do this same thing with another directory but also allow the apache user to read files in the directory and serve them.
What's the best way to set this up?