Skip to content

Permissions in Linux

Special permissions add extra behavior beyond normal rwx rights:

  • setuid: Executable runs as the file owner.
  • setgid: Executable runs as the file’s group; directories enforce group inheritance.
  • sticky bit: In a directory, only root, the file owner, or the directory owner can delete/rename files—even if others have 777.

  • Symbolic: u+s, g+s, +t
  • Numeric: First digit in chmod represents special bits:
    • 4 = setuid
    • 2 = setgid
    • 1 = sticky bit
  • Combine them by addition:
    • chmod 4755 file → setuid + rwxr-xr-x
    • chmod 2755 dir → setgid + rwxr-xr-x
    • chmod 1755 dir → sticky + rwxr-xr-x
    • chmod 6755 file → setuid + setgid + rwxr-xr-x

Special BitEffectSymbolicNumericExample CommandExample ls -l Output
setuidExecutable runs with owner’s UIDu+s4000chmod 4755 /usr/bin/sudo---s--x--x. 1 root root ... /usr/bin/sudo
setgidExecutable runs with file’s GID; directories enforce group inheritanceg+s2000chmod 2555 /usr/bin/wall-r-xr-sr-x. 1 root tty ... /usr/bin/wall
sticky bitIn directory: only root, file owner, or dir owner can delete/rename files+t1000chmod 1777 /tmpdrwxrwxrwt. 11 root root ... /tmp

chmod [special][owner][group][others]
^ ^ ^ ^
| | | |
| | | └─ others permissions (rwx)
| | └──────── group permissions (rwx)
| └─────────────── owner permissions (rwx)
└─────────────────────── special bits (4=setuid, 2=setgid, 1=sticky)

  • Sticky bit only affects deletion/rename, not read/write/execute.
  • s replaces x in user/group execute position when setuid/setgid is active.
  • t replaces x in others execute position when sticky bit is active.