1. Create a new group SHAREDGROUP and create a shared folder SHAREDFOLDER
2. Add the users you want to be in the group (edit the /etc/group file)
3. In the bash profile of *each* user (~/.bash_profile) add the following
umask 0002
find SHAREDFOLDER -user OWNUSERNAME -exec chown OWNUSERNAME:SHAREDGROUP {} \;
find SHAREDFOLDER -user OWNUSERNAME -exec chmod -R 775 {} \;
Explanation:
- Go to the shared folder
- Find all data owned by the user
- Change the group owner of the data to the data sharing group
- Change the permissions so that group members can write
Alternative (not preferable):
(chown -R lu:datashare /storage/lu/data &) 2>/dev/null
(chmod -R 775 /storage/lu/data &) 2>/dev/null
4. After you add or modify files in the shared data folder, you need to either log in the shell again or type source ~/.bash_profile
Alternatively you can have a daemon running and sourcing the profiles of all users in fixed intervals.
Limitations
This only works for sharing one folder with one group.
You cannot share the folder with multiple distinct groups and similarly there is no group hierarchy.
To achieve such more complex schemes, you need to use ACLs.