Interview Q&A / Linux & Shell

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is the sticky bit, and why does /tmp have it?

SHORT ANSWER

The sticky bit on a directory means only a file's owner, the directory's owner or root may delete or rename files inside, even if others have write permission on the directory. It shows as a t at the end of the permissions, for example drwxrwxrwt.

Explain it simply

A shared notice board in a hostel lets everyone pin papers. Without any rule, anyone could also tear down your paper. The sticky bit adds the rule: you can remove only your own notes.

Normally, deleting a file depends on write permission on the directory, not on the file. In a world-writable folder like /tmp, that would let any user delete anyone else's files. With the sticky bit set, deletion and renaming are limited to the file owner, the directory owner and root.

Set it with chmod +t dir or chmod 1777 dir. In ls -l it appears as t in the others' execute slot (drwxrwxrwt), or a capital T if others lack execute permission.

On regular files, modern Linux ignores the sticky bit.

Example

bash
mkdir shared
chmod 1777 shared
ls -ld shared
# drwxrwxrwt 2 user user 4096 ... shared

What to say in the interview

"The sticky bit on a directory restricts deletion and renaming to the file's owner, the directory's owner or root, even when the directory is world-writable. /tmp uses it (mode 1777) so users cannot remove each other's files."

Common mistakes

  • Thinking the sticky bit makes files undeletable; owners and root can still delete.
  • Mixing up t and T in the ls output.

#linux#permissions#sticky-bit

Related questions

Practise more Linux & Shell questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Linux & Shell quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.