I know that a file that is created in a directory with the GID-bit set it will inherit the diretory's group ownership. This however doesn't work for files that are moved to that directory as stated in https://en.wikipedia.org/wiki/Setuid#setuid_and_setgid_on_directories
It happens that users move files to a shared folder instead of copying them or creating new files, there are now files in the shared folder that are not accessible to everybody.
There is a shread folder
john:/home/common$ ls -l drwxrws--- 15 john users 4096 Feb 11 09:14 shared
and a file in a private folder.
john:/home/john$ ls -l -rw-rw---- 1 john john 512 Feb 11 09:14 test.txt
That file is moved to the shared folder. It keeps the group ownership.
john:/home/common/shared$ mv /home/john/test.txt . john:/home/common/shared$ ls -l -rw-rw---- 1 john john 512 Feb 11 09:14 test.txt
When the file is moved to
shared, the group stays
john and is not changed to
users. If the file is copied, the group changed to
Even though this behaviour is logical from a system point of view, it is not what is expected from a user point of view.
Is there a way to configure the
shared directory so that the group is also changed automatically for files that are moved?
What is the best practice to achieve this goal?