{
  "slug": "setgid-directory",
  "term": "Setgid directory",
  "aliases": [
    "SGID directory",
    "set-group-ID directory"
  ],
  "definition": "On Linux, a setgid directory gives newly created children its group ownership and passes the set-group-ID bit to newly created subdirectories.",
  "note": "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. [inode] [mkdir]\n\nPermissions: 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. [open] [acl]\n\nCalculated 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. [open] [mkdir]\n\nFilesystem 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. [chown]\n\nRecovery: 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. [inode] [acl]",
  "related": [
    "directory",
    "default-acl",
    "posix-access-control-list",
    "umask",
    "chown"
  ],
  "citations": [
    {
      "id": "inode",
      "title": "Linux man-pages: inode(7), S_ISGID on directories and executables",
      "url": "https://man7.org/linux/man-pages/man7/inode.7.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "mkdir",
      "title": "Linux man-pages: mkdir(2), group ownership and setgid inheritance",
      "url": "https://man7.org/linux/man-pages/man2/mkdir.2.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "open",
      "title": "Linux man-pages: open(2), O_CREAT mode and group ownership",
      "url": "https://man7.org/linux/man-pages/man2/open.2.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "acl",
      "title": "Linux ACL project: acl(5), object creation and permission classes",
      "url": "https://man7.org/linux/man-pages/man5/acl.5.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "chown",
      "title": "Linux man-pages: chown(2), new-file group ownership and mount policy",
      "url": "https://man7.org/linux/man-pages/man2/chown.2.html",
      "accessed": "2026-11-15"
    }
  ],
  "status": "shipping",
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-16",
  "advantages": [],
  "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."
  ],
  "provenance": [
    "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."
  ]
}
