Setgid (Set Group ID): Controlling Default Group Ownership
The setgid bit (SGID) ensures that files and directories created within a directory inherit the group ownership of the parent directory, rather than the primary group of the user creating them. This is particularly useful in collaborative environments where multiple users share access to project directories.
New subdirectories inherit the parent directory's setgid bit.
When viewing directory permissions with ls -ld, the setgid bit appears as:
s(lowercase) in the group execute field if execute (x) permissions are also set.S(uppercase) in the group execute field if execute (x) permissions are not set.
Example
Disk quota exceeded
If the setgid bit is not set, new files and directories will inherit the user's primary group, which may lead to permission issues or "Disk quota exceeded" errors."
For files, the setgid bit is usually unnecessary and potentially risky.