Suppose I have two users Alice and Bob and a group GROUPNAME and a folder foo
, both users are members of GROUPNAME (using Linux and ext3).
If I save as user Alice a file under foo
, the permissions are: -rw-r--r-- Alice Alice
. However, is it possible to achieve that every file saved under some subdirectory of foo
has permissions -rwxrwx--- Alice GROUPNAME
(i.e. owner Alice, group GROUPNAME)?
Best Answer
You can control the assigned permission bits with
umask
, and the group by making the directory setgid toGROUPNAME
.Note that you have to do the
chgrp
/chmod
for every subdirectory; it doesn't propagate automatically (that is, neither existing nor subsequently created directories under a setgid directory will be setgid, although the latter will be in groupGROUPNAME
).Also note that
umask
is a process attribute and applies to all files created by that process and its children (which inherit theumask
in effect in their parent atfork()
time). Users may need to set this in~/.profile
, and may need to watch out for things unrelated to your directory that need different permissions. modules may be useful if you need different settings when doing different things.You can control things a bit better if you can use POSIX ACLs; it should be possible to specify both a permissions mask and a group, and have them propagate sensibly. Support for POSIX ACLs is somewhat variable, though.