MKTEMP(1) General Commands Manual MKTEMP(1)

mktempmake a new randomly-named file or directory

mktemp [-dqtu] [-p tempdir] [template]

mktemp creates a new randomly-named file or directory, and prints its name.

template must contain at least 6 consecutive ‘X’ as last path component. If template is not specified, ‘tmp.XXXXXXXXXX’ is used instead.
Files are created with u+rw permissions, directories with u+rwx.

Create a directory, not a file.
Quiet messages about file/directory creation failure.
tempdir
Specify tempdir as an existing directory to create into. Overrides TMPDIR.
Use TMPDIR or if unset, /tmp, as an existing directory to create into.
Unsafe mode, generate filename and print it out without creating it.

Only present for compatibility with existing scripts, do not use.

The mktemp utility exits 0 on success, and >0 if an error occurs.

An mktemp utility first appeared in NetBSD 1.5 and OpenBSD 2.1

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

2024-09-20 Linux 6.6.67-gentoo-x86_64