Note: This is an RHCSA 7 exam objective.

Let’s assume two users belonging to the team group, user01 and user02, who want to share a directory called shared.

Create the team group:

# groupadd -g 50000 team

Create the shared directory:

# mkdir /home/shared

Change the ownership of the directory:

# chown nobody:team /home/shared

Assign the set group ID bit (SGID) to the directory:

# chmod g+s /home/shared

Allow the members of the team group to write into the shared directory:

# chmod g+w /home/shared

Remove the permissions for all other users:

# chmod o-rwx /home/shared

Note: The three last commands can be resumed in only one to choose among these:

# chmod g+ws,o-rwx /home/shared
# chmod 2770 /home/shared

Create the two users and assign them the team group in addition to their own group:

# useradd -G team user01
# useradd -G team user02

Note: This can be done in two steps:

# useradd user0X; usermod -aG team user0X

Check the configuration:

# su - user01
$ cd /home/shared
$ touch nothing
$ ls -l
total 0
-rw-rw-r--. 1 user01 team 0 Nov 12 09:45 nothing

Finally, if you want the team group members to be able to see each other’s files but not to delete them, type:

# chmod +t /home/shared