Pcornel
Linux · Permissions & Ownership

Sticky Bit

Cheat sheet · https://pcornel.dk/topic.php?topic=2710

Back to the Topic

Answer

The sticky bit (mode 1xxx, t in the others execute position) on a directory lets only a file's owner (or root) delete or rename it, even if others can write to the directory — as on /tmp.

Remember

/tmp and /var/tmp should be 1777. Without it, any user with write access to the directory can remove anyone's files.

First checks

  • ls -l <path> — owner, group and mode
  • stat -c '%A %a %U:%G' <path> — symbolic and numeric mode with owner
  • namei -l <path> — permissions of every directory on the path
  • id <user> — user's groups

Verify in this order

writable directory with sticky bit → delete or rename requested → kernel allows only the file owner, directory owner or root

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2710

Confirmation

Confirm action

Continue?