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