What is the best way to share a directory between multiple Linux users?
Say I have a directory at
/foo (a regular directory no NFS or else) and a bunch of users added to the group
What I want is this behavior:
- all users in
barcan read/write files and directories in
- any files and directories created in
/foois automatically readable/writable by all users in
I am not sure what is the best way to do this:
I can set the group of
/fooand its initial content to be in the
chown -R :barand set the setgid it on these with
chmod -R g+s. I leave the umask to the default (02). There may be weird side effects to setgid on files too (the libmagic filetype get prefixed with
setgid,with unpredictable results for apps that use this).
Or I set the umask to something else for all users (say 03 or 07) but I am not sure I can get the right sharing to take place short of also using the setgid bit.
My question: what is the best, cleanest and idiomatic way to achieve this file sharing setup reliably?
PS: I wrote in the title "peacefully sharing a directory" as a tongue-in-cheek and by this I mean reliably and consistently. I think I have never been able to achieve this sharing reliably without rogue files popping up and not being accessible to the group with any setting I could try.