setgid-directory · shipping · also SGID directory, set-group-ID directory

Setgid directory

On Linux, a setgid directory gives newly created children its group ownership and passes the set-group-ID bit to newly created subdirectories.

Related Observatory article: Read on hesela.com

Ownership: directory S_ISGID (02000) gives new children the parent's group; new subdirectories also inherit that bit. This differs from credential changes when executing a setgid program. [1] [2]

Permissions: group inheritance does not itself grant group write. For regular files created with open()/creat() and directories created with mkdir(), with no parent default ACL, requested_mode & ~umask & 0777 gives ordinary permission bits. A default ACL instead initializes an access ACL constrained by the requested mode. [3] [4]

Calculated example: assume successful creation under a setgid parent, no default ACL and umask 0027. A regular-file request for 0666 yields 0640; a subdirectory request for 0777 yields 0750 plus inherited 02000, conventionally 2750. Both receive the parent's group; neither is group-writable. These are derived examples, not new native observations or complete st_mode values. [3] [2]

Filesystem scope: supporting filesystems can use grpid/bsdgroups to inherit the parent group without parent S_ISGID. With nogrpid and no parent setgid bit, Linux uses the process's filesystem GID. A child's group alone does not identify the inheritance rule. [5]

Recovery: directory group ownership and setgid state are separate from access and default ACLs. Setting this bit on the directory alone does not retroactively change existing children's groups or permissions. [1] [4]

Relations

related
Directory, Default ACL, POSIX access control list, File mode creation mask (umask), chown

Limitations

  • Linux directory semantics are not a universal ACL or filesystem contract.
  • Group inheritance is not an authorization test and does not imply group write permission.

Citations

  1. Linux man-pages: inode(7), S_ISGID on directories and executables (accessed 2026-11-15)
  2. Linux man-pages: mkdir(2), group ownership and setgid inheritance (accessed 2026-11-15)
  3. Linux man-pages: open(2), O_CREAT mode and group ownership (accessed 2026-11-15)
  4. Linux ACL project: acl(5), object creation and permission classes (accessed 2026-11-15)
  5. Linux man-pages: chown(2), new-file group ownership and mount policy (accessed 2026-11-15)
Sources & caveats
  • Primary-source synthesis with explicitly calculated permission examples. No new native permission, restore or security experiment was performed.
  • Human context: https://hesela.com/analyses/posix-acl-restore-permissions/
  • Verifying future child creation as well as restored objects is an engineering inference. Identity mapping and destination filesystem behavior need separate acceptance.

JSON: /data/terms/setgid-directory.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Setgid directory. Hesela. 2026-11-16. https://hesela.dev/terms/setgid-directory/