The devs team, alice and bob, keeps shared files in /srv/team. The directory belongs to the devs group, and the group may write to it. Watch the two of them at work: alice puts a plan there, bob tries to append to it and then tidies the directory up.
The commands for alice and bob run through sudo -u, as in the previous lesson. Start creates both accounts and the directory.
Watch the shared directory at work
Run the commands in order: alice creates plan.txt in /srv/team, you look at ls -l, bob tries to append to the file and then deletes it.
First, predict
Which group will ls -l show for plan.txt?
Now start the exercise, run the command and compare your prediction with the output.
Why could bob not append to plan.txt even though he is in the devs group?
-
tee -aappends to any file where the process hasw. bob has none: the file's group is alice, and he got ther--triple. -
sudo -ustarts a new process and reads the groups again:sudo -u bob idshows devs. -
bob can write to the directory through the devs group:
rm -fvdeleted plan.txt, and deleting changes the directory.
plan.txt is in the group alice, which bob does not belong to, so the others triple r-- applied to him.