Session and utilities

The mktemp command

Creates a temporary file or folder with a unique, safe name, so it does not clash with others.

Syntax

mktemp [-d]

Most useful options

-dCreates a temporary directory

Copy-ready examples

$ mktempUnique temporary file

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • The created file is yours and private, but it does not delete itself: manage its cleanup.

Related commands

FAQ

Why not use /tmp/myfile?

Because another program could use the same name; mktemp guarantees uniqueness.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course