The “Sticky Bit” for Temporary Files

Quick Tip

The “Sticky Bit” for Temporary Files

Challenge: You need to create a directory where multiple users can create files, but they should only be able to delete their *own* files, not those created by others. This is common for temporary upload or processing directories.

The Solution: Use the `sticky bit` on the directory. This is achieved by setting the `t` permission. For example, to create a temporary upload directory:

sudo mkdir /srv/shared_temp sudo chmod 1777 /srv/shared_temp

Why it works: The sticky bit (represented by the leading ‘1’ in octal or ‘t’ in symbolic notation) on a directory prevents users from deleting or renaming files within that directory unless they are the owner of the file or the owner of the directory (or root). This is the same mechanism used by `/tmp`.

Pro-Tip: You can check for the sticky bit by looking for a `t` at the end of the permissions string for a directory: ls -ld /srv/shared_temp. If it’s uppercase `T`, it’s set but the execute bit isn’t, meaning it’s effectively off.

Linux Tips & Tricks | © ngelinux.com | 5/4/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments