The group ownership can be inherited by new files and folders created in your folder /path/to/parent by setting the setgid bit using
chmod g+s
like this:chmod g+s /path/to/parent
Now, all new files and folder created under /path/to/parent will have the same group assigned as is set on /path/to/parent.
POSIX file permissions are not inherited; they are given by the creating process and combined with its current umask value.However, you can use POSIX ACLs to achieve this. Set the default ACL on a directory:
setfacl -d -m u::rwX,g::rwX,o::- /path/to/parent
This will apply
setfacl
to the /path/to/parent directory, -m
odifying the -d
efault ACLs – those that will be applied to newly created items. (Uppercase X
means only directories will receive the +x
bit.)(If needed, you can add a
u:someuser:rwX
or g:someuser:rwX
– preferably a group – to the ACLs.)Note that, at least with ext3/ext4, you must mount the filesystem with the
acl
option, otherwise new ACLs cannot be set and existing ones will be ignored.
mount -o remount,acl /
Edit
/etc/fstab
to set this permanently.