Last Updated: February 25, 2016
·
595
· walkeran

setgid bit on directories

Set the setgid bit on directories to cause new files and dirs created inside of it to inherit its group ID, instead of the primary group ID of the user who created it.

Example:

# mkdir foo
# chgrp users foo
# touch foo/without_setgid
# ls -l foo/without_setgid 
-rw-r--r-- 1 root root 0 Dec 12 14:24 foo/without_setgid
# chmod g+s foo
# touch foo/with_setgid
# ls -l foo/with_setgid 
-rw-r--r-- 1 root users 0 Dec 12 14:24 foo/with_setgid