How can a file moved to a directory with GID-bit set inherit the group ownership
Solution 1:
The setgid does affect the newly created files (using touch
, cp
), and it does not affect the already created files (using mv
).
There are several solutions like the ones posted here. Also, you can add a cron job to periodically chgrp
all files / folders under your shared folder.
Another possible solution is to use incrontab -e
to fix group ownership when a file is moved to your shared folder. Be careful, this triggers events only for shared folder itself not any other subfolder.
/path/to/shared/dir IN_MOVED_TO /bin/chgrp users $@/$#