What is a setgid?
27 May 2024 (Updated 27 May 2024)
The setgid (Set Group ID) bit is a special type of permission in Unix-like operating systems that can have different effects, depending on whether it’s set on an executable file or a directory.
Setgid on directories
When the setgid bit is set on a directory, it ensures that any files or subdirectories created within that directory inherit the group ownership of the directory, rather than the primary group of the user who created the file/subdirectory.
Setgid on executable files
When the setid bit is set on an executable file, the process that runs the file will run with the privileges of the file’s group, rather than the group of the user who executed the file.
Recipes
Set setgid on a directory/executable
sudo chmod g+s <file-or-directory>
Remove setgid from a file/directory
sudo chmod g-s <file-or-directory>
Tagged:
Unix
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment