Having write permission on a directory is, by default, enough to delete any file inside it, including one owned by a different user: the permission that actually matters for deletion is the directory’s, never the file’s own. /tmp, shared by every user on a machine, deliberately breaks that rule using the sticky bit.

The default rule, often misunderstood

Deleting a file, from the kernel’s point of view, means removing a directory entry, an operation that never directly touches the file or its own permissions. That’s why a read-only file (chmod 444) can still be deleted by anyone with write access to the parent directory, a frequent surprise for anyone reasoning purely in terms of the file’s own permissions.

# A read-only file, seemingly protected...
chmod 444 file.txt
# ...but still deletable if the parent directory
# is writable, regardless of the file's own permissions
rm file.txt

What the sticky bit actually changes

The sticky bit (chmod +t, visible as a t in place of the x in the “others” permissions) restricts deleting a file in a directory to the file’s owner, the directory’s owner, or root, regardless of the write permission granted to everyone on that directory.

# /tmp carries the sticky bit on nearly every
# modern distribution, by default
ls -ld /tmp
# drwxrwxrwt 20 root root ... /tmp
#          ^ the "t" replaces the "others" "x"

Without this bit, a world-writable /tmp (necessary so every user can create their own temp files) would let anyone delete anyone else’s temporary files, an obvious security problem on a machine shared across multiple users or services.

The connection to the same family of special bits

The sticky bit belongs to the same family as the already-covered setuid and the lesser-known setgid (which makes new files in a directory inherit that directory’s group rather than the creating user’s primary group): all three bits change a default filesystem behavior for security or collaboration reasons, each along a different axis (privilege elevation for setuid, group inheritance for setgid, deletion protection for the sticky bit).

Takeaway

Permission to delete a file depends on the parent directory, not the file itself, a default rule that would let anyone delete other users’ temporary files on a shared directory like /tmp. The sticky bit restricts that deletion to the file’s owner, the directory’s owner, or root, a setting visible via the t in ls -ld and active by default on /tmp on nearly every modern distribution. Along with setuid and setgid, it completes the family of special permission bits, each changing a different default Linux filesystem behavior for a specific security or collaboration need.