Setting the SGID bit and the sticky bit on the shared directory
I’ve told you before that it’s a bit of a security risk to set either the SUID or SGID permissions on files, especially on executable files. But it is both completely safe and very useful to set SGID on a shared directory.
SGID behavior on a directory is completely different from SGID behavior on a file. On a directory, SGID will cause any files that anybody creates to be associated with the same group with which the directory is associated.
So, bearing in mind that the SGID permission value is 2000
, let’s set SGID on our marketing
directory:
[donnie@localhost /]$ sudo chmod 2770 marketing
[sudo] password for donnie:
[donnie@localhost /]$ ls -ld marketing
drwxrws---. 2 nobody marketing 28 Nov 13 15:41 marketing
[donnie@localhost /]$
The s
in the executable position for the group indicates that the command was successful. Let’s now let Vicky log back in to create another file...