Sharing data

Unix groups

exits for each file and directory stored on the HOME or WORK file systems:

Each user ID is member of one or more groups. Group memberships can be checked with the groups command.

Show group memberships
blogin4:~ $ groups myaccount
myaccount prj00012

You can change the group ownership of a file:

Change group ownership
blogin4:~ $ chgrp prj00012 somefile.txt
blogin4:~ $ ls -l somefile.txt
-rw-------  1 myaccount prj00012 237271040 Jul  3  2020 somefile.txt

To change all small number of files in a directory recursively, use "chgrp -R".

Change group ownership of a directory and everything it contains
blogin4:~ $ find somedirectory | xargs chgrp prj00012 
blogin4:~ $ ls -ld somedirectory
drwx------  1 myaccount  prj00012      4096 Jul  3  2020 somedirectory

Access for group members

Once a file (or a complete directory) has the group ownership, the file might be accessed by all users in the group.

File access for group
blogin4:~ $ ls -l somefile.txt
-rw-------  1 myaccount prj00012 237271040 Jul  3  2020 somefile.txt
blogin4:~ $ chmod g+r somefile.txt
blogin4:~ $ ls -l somefile.txt
-rw-r-----  1 myaccount prj00012 237271040 Jul  3  2020 somefile.txt
Directory access for group
blogin4:~ $ ls -ld somedirectory
drwx------  1 myaccount  prj00012      4096 Jul  3  2020 somedirectory
blogin4:~ $ find somedirectory |xargs chmod g+rX
blogin4:~ $ ls -ld somedirectory
drwxr-x---  1 myaccount  prj00012      4096 Jul  3  2020 somedirectory