Sticky bit vs setgid for facilitating shared write access

filespermissions

Say two people with different primary unix GIDs share and need to frequently edit the same file. The users are not members of each others' primary unix GIDs, but they are both members of a common second group.

The accepted answer (and other posted answers) to this question suggest setting the sticky bit on the file's parent directory so that such a file does not get the user's primary group ID whenever one of the users modifies the file (i.e. they claim it removes the need to call newgrp in every login session whenever one of the users wants to edit the shared file)

However I thought that something like this could only be done with with the setgid bit.

From Wikipedia:

Setting the setgid permission on a directory (chmod g+s) causes new
files and subdirectories created within it to inherit its group ID,
rather than the primary group ID of the user who created the file (the
owner ID is never affected, only the group ID).

Why would the sticky bit help with this?

Best Answer

You're right, it's the setgid bit that has this effect. The sticky bit has an effect on a directory too, but it's unrelated: it means that only the owner of a file can delete it, as opposed to anyone with write permission on the directory (think /tmp).

Related Question