Frequently Asked Question

What's the difference between /tmp and /var/tmp?

Both directories are world-writable scratch space for programs to create files, and both use the sticky bit so that one user cannot delete another's files even though the directory is writable by all. The difference is persistence. /tmp is intended for short-lived files and is typically wiped at reboot, on most modern systems it is in fact a tmpfs mount (RAM-backed), so its contents disappear the moment the machine powers down. /var/tmp is the opposite: it lives on persistent storage, and the FHS guarantees that its contents survive across reboots. Files there are usually purged only after 30 days by systemd-tmpfiles.

The practical rule: if the file is bounded in size and only needed for the current session, a Unix socket, a lockfile, an intermediate compilation step, use /tmp. If the file is large or must survive an unexpected reboot, a half-finished download, the state of an interactive editor session, a pacman lockdir holding partial extraction; use /var/tmp. Never put anything important in either: both are designed to be cleanable at any moment.

Further reading and video