MKTEMP(1)

๐Ÿ’– MKTEMP(1) โ€” the girliepop guide to making temp files ๐Ÿ’–

okay so bestie, welcome to mktemp(1), straight out of the User Commands section. this is the one that makes you a temporary file or a temporary directory safely and then yells the name back at you so you can actually use it. no cap. โœจ


โœจ NAME โœจ

mktemp โ€” create a temporary file or directory ๐ŸŽ€


๐ŸŒธ SYNOPSIS ๐ŸŒธ

mktemp [OPTION]... [TEMPLATE]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so the whole vibe is this: you want a temp file or dir, you want it made safely, and you want the name printed out so you can go do your little thing with it. that's it, that's the whole job. ๐Ÿ’…

your TEMPLATE has to have at least 3 consecutive Xs in the last component. that's the whole rule, don't fight it. and if you don't pass a TEMPLATE at all? no stress, it just uses tmp.XXXXXXXXXX, and --tmpdir gets implied for you. so thoughtful. ๐Ÿซถ

and listen, the perms are specific: files get created u+rw, and directories get u+rwx, and then umask restrictions get subtracted from all that. periodt.

here's the full option menu, bestie, and yes we're going through every single one:

  • -d, --directory โ€” make a directory, not a file. that's it. that's the whole thing. ๐ŸŽ€
  • -u, --dry-run โ€” don't create anything at all, just print a name. and ngl, this one is unsafe, the manpage literally says so, so likeโ€ฆ be aware. ๐Ÿ’€
  • -q, --quiet โ€” shuts up the diagnostics when file/dir creation fails. silent but deadly. ๐Ÿ™ˆ
  • --suffix=SUFF โ€” sticks SUFF onto the end of your TEMPLATE. important: SUFF must not contain a slash. also this option gets implied automatically if your TEMPLATE doesn't end in X. ๐Ÿ˜Œ
  • -p DIR, --tmpdir[=DIR] โ€” reads your TEMPLATE as relative to DIR. if you don't give a DIR, it uses $TMPDIR if that's set, otherwise /tmp. and here's the tea: with this option your TEMPLATE must not be an absolute name, and unlike with -t, your TEMPLATE is allowed to contain slashes โ€” but mktemp only ever creates the final component. just the last one. don't get it twisted. ๐Ÿงš
  • -t โ€” reads TEMPLATE as a single file name component, relative to a directory: $TMPDIR if it's set; otherwise the directory you gave via -p; otherwise /tmp. and bestieโ€ฆ this one is [deprecated]. it's giving legacy energy. it still works but like, iykyk. โญ
  • --help โ€” displays this help and dips. ๐Ÿ‘‹
  • --version โ€” outputs version info and dips. ๐Ÿ’œ
โš ๏ธ real talk: -u / --dry-run is flagged unsafe right there in the source material, and -t is flagged deprecated. i'm not adding lore, i'm just repeating the warning label. take it seriously. ๐Ÿ”ฅ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by Jim Meyering and Eric Blake. absolute icons, honestly. ๐ŸŒˆ


๐Ÿ˜ญ REPORTING BUGS ๐Ÿ˜ญ

found something cursed? tell the girlies:


Copyright ยฉ 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

not me being legally obligated to say there's no warranty. there's no warranty bestie. to the extent permitted by law. ๐Ÿซถ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Full documentation <https://www.gnu.org/software/coreutils/mktemp>

or available locally via: info '(coreutils) mktemp invocation'


and that's the whole page, bestie!! this was GNU coreutils 9.12, dated September 2026, and you read it all the way to the end which is genuinely iconic of you. go make a temp file. slay. ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from