{
    "mode": "man",
    "parameter": "mktemp",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/mktemp/1/json",
    "generated": "2026-06-02T20:22:01Z",
    "synopsis": "mktemp [OPTION]... [TEMPLATE]",
    "sections": {
        "NAME": {
            "content": "mktemp - create a temporary file or directory\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "mktemp [OPTION]... [TEMPLATE]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Create  a  temporary file or directory, safely, and print its name.  TEMPLATE must contain at\nleast  3  consecutive  'X's  in  last  component.   If  TEMPLATE  is   not   specified,   use\ntmp.XXXXXXXXXX,  and --tmpdir is implied.  Files are created u+rw, and directories u+rwx, mi‐\nnus umask restrictions.\n",
            "subsections": [
                {
                    "name": "-d --directory",
                    "content": "create a directory, not a file\n",
                    "flag": "-d",
                    "long": "--directory"
                },
                {
                    "name": "-u --dry-run",
                    "content": "do not create anything; merely print a name (unsafe)\n",
                    "flag": "-u",
                    "long": "--dry-run"
                },
                {
                    "name": "-q --quiet",
                    "content": "suppress diagnostics about file/dir-creation failure\n\n--suffix=SUFF\nappend SUFF to TEMPLATE; SUFF must not contain a slash.  This  option  is  implied  if\nTEMPLATE does not end in X\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-p --tmpdir",
                    "content": "interpret  TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR if set, else\n/tmp.  With this option, TEMPLATE must not be an absolute name; unlike with  -t,  TEM‐\nPLATE may contain slashes, but mktemp creates only the final component\n",
                    "flag": "-p",
                    "long": "--tmpdir"
                },
                {
                    "name": "-t",
                    "content": "if set; else the directory specified via -p; else /tmp [deprecated]\n\n--help display this help and exit\n",
                    "flag": "-t"
                },
                {
                    "name": "--version",
                    "content": "output version information and exit\n",
                    "long": "--version"
                }
            ]
        },
        "AUTHOR": {
            "content": "Written by Jim Meyering and Eric Blake.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2020 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3  or  later\n<https://gnu.org/licenses/gpl.html>.\nThis  is free software: you are free to change and redistribute it.  There is NO WARRANTY, to\nthe extent permitted by law.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "mkstemp(3), mkdtemp(3), mktemp(3)\n\nFull documentation <https://www.gnu.org/software/coreutils/mktemp>\nor available locally via: info '(coreutils) mktemp invocation'\n\n\n\nGNU coreutils 8.32                          January 2026                                   MKTEMP(1)",
            "subsections": []
        }
    },
    "summary": "mktemp - create a temporary file or directory",
    "flags": [
        {
            "flag": "-d",
            "long": "--directory",
            "arg": null,
            "description": "create a directory, not a file"
        },
        {
            "flag": "-u",
            "long": "--dry-run",
            "arg": null,
            "description": "do not create anything; merely print a name (unsafe)"
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "suppress diagnostics about file/dir-creation failure --suffix=SUFF append SUFF to TEMPLATE; SUFF must not contain a slash. This option is implied if TEMPLATE does not end in X"
        },
        {
            "flag": "-p",
            "long": "--tmpdir",
            "arg": null,
            "description": "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; unlike with -t, TEM‐ PLATE may contain slashes, but mktemp creates only the final component"
        },
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "if set; else the directory specified via -p; else /tmp [deprecated] --help display this help and exit"
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "output version information and exit"
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "mkstemp",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/mkstemp/3/json"
        },
        {
            "name": "mkdtemp",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/mkdtemp/3/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Create a temporary file or directory.",
        "examples": [
            {
                "description": "Create an empty temporary file and print its absolute path",
                "command": "mktemp"
            },
            {
                "description": "Use a custom directory if `$TMPDIR` is not set (the default is platform-dependent, but usually `/tmp`)",
                "command": "mktemp -p /{{path/to/temporary_directory}}"
            },
            {
                "description": "Use a custom path template (`X`s are replaced with random alphanumeric characters)",
                "command": "mktemp {{/tmp/example.XXXXXXXX}}"
            },
            {
                "description": "Use a custom file name template",
                "command": "mktemp -t {{example.XXXXXXXX}}"
            },
            {
                "description": "Create an empty temporary directory and print its absolute path",
                "command": "mktemp -d"
            }
        ]
    }
}