# mktemp

*noun*

say it: **“EM-kay-temp”** **/ˈɛmˌkeɪˌtɛmp/**

A command that makes an empty file or folder with a new random name and prints that name, for scratch work.

## What does **mktemp** do?

`mktemp` makes an empty file with a name no other file has, and prints the name, so two copies of a script never write over each other's scratch work. `-d` makes a folder. Given a name ending in X's, it puts the file there and swaps each X for a random letter or digit.

```bash
tmp=$(mktemp)
echo "$tmp"                    # /tmp/tmp.fnPP9aOBRq
mktemp photos/.moving.XXXXXX   # photos/.moving.AE9l07
```

## In a sentence

- “**mktemp** gave the mover a hidden scratch file named .moving.AE9l07.”
- “Two copies of the script ran at once, and **mktemp** made sure their scratch files never shared a name.”

Level: Journeyman · [More Unix terms at this level](https://www.ask-codey.com/glossary?category=unix&level=3)

Updated: November 10, 2026

Source: https://www.ask-codey.com/glossary/mktemp
