whatis tmp-directory
/tmp
Also known as: temporary directory, tmpfs
The world-writable directory for temporary files, often backed by RAM (tmpfs) and cleared on reboot.
What Is the /tmp Directory in Linux?
Any user can create files in /tmp, and the sticky bit stops them deleting each other's. Many distros mount it as tmpfs, so contents live in memory and vanish on reboot; /var/tmp is the place for temp files that should survive.
Scripts should create temp files with mktemp rather than fixed names, which avoids collisions and symlink attacks.
Example
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT Learn more about /tmp
- The /tmp Directory Explained /tmp is Linux's designated scratch space for temporary files, often cleared on every reboot. This guide explains how /tmp works, why it is sometimes stored in RAM, and how it differs from /var/tmp.