mktemp
file managementLinux/Unix
The mktemp command is one of the most frequently used commands in Linux/Unix-like operating systems. mktemp Create a temporary file or directory
Quick Reference
Command Name:
mktemp
Category:
file management
Platform:
Linux/Unix
Basic Usage:
mktemp [options] [arguments]
Common Use Cases
Syntax
mktemp [OPTION]... [TEMPLATE]
Options
Option | Description |
---|---|
-d, --directory |
Create a directory instead of a file |
-u, --dry-run |
Do not create anything; merely print a name |
-q, --quiet |
Suppress error messages about file or directory creation failure |
--suffix=SUFFIX |
Append SUFFIX to TEMPLATE; SUFFIX must not contain a slash |
-p DIR, --tmpdir[=DIR] |
Interpret TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR if set, else /tmp. With this option, TEMPLATE must not be an absolute name |
-t |
Interpret TEMPLATE as a single file name component, relative to a directory: $TMPDIR, if set; else the directory specified via -p; else /tmp |
--help |
Display help information and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the mktemp
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
mktemp