mktemp(1) on Solnix vs Linux and the BSDs
On Solnix, mktemp is the illumos mktemp at /usr/bin/mktemp. Its option set matches the OpenBSD page: -t is a flag, not an option with an argument as on FreeBSD and NetBSD. -u creates then unlinks the file, where Linux -u/--dry-run creates nothing. Portable `mktemp -t prefix` calls are the likeliest to break.
The manual pages
What Solnix runs
A default Solnix system runs the illumos mktemp at /usr/bin/mktemp. No other variants are shipped. The Solnix page says the utility appeared in OpenBSD 2.1, and its options and wording closely follow the OpenBSD page.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| FreeBSD, NetBSD | -t takes an argument on the BSDs | On Solnix, -t is a plain flag, and the template (if given) must be a single directory component. On FreeBSD and NetBSD, -t takes a prefix argument. The Solnix page does not say what `mktemp -t prefix` does when the template has no Xs.Source: Solnix mktemp(1) OPTIONS -t, OPERANDS; FreeBSD mktemp(1) SYNOPSIS, -t prefix; NetBSD mktemp(1) SYNOPSIS, -t prefix |
| Linux | -u / --dry-run | Solnix -u creates the file, then unlinks it before exit, which the page calls a race condition and discourages. Linux -u (--dry-run) does not create anything and only prints a name.Source: Solnix mktemp(1) -u; Linux mktemp(1) -u, --dry-run |
| Linux, FreeBSD | long options | Solnix has only the short options -d, -p, -q, -t and -u. Linux and FreeBSD also accept --directory, --quiet, --dry-run and --tmpdir. Linux also has --help, --version and --suffix. OpenBSD and NetBSD, like Solnix, list no long options.Source: Solnix mktemp(1) SYNOPSIS; Linux mktemp(1) options; FreeBSD mktemp(1) OPTIONS; OpenBSD mktemp(1) SYNOPSIS; NetBSD mktemp(1) SYNOPSIS |
| Linux | --suffix and templates not ending in X | Solnix has no --suffix. Its template is a filename with Xs appended to it. Linux --suffix=SUFF appends text after the Xs, and is implied when TEMPLATE does not end in X. Linux needs at least 3 consecutive Xs in the last component.Source: Solnix mktemp(1) OPERANDS; Linux mktemp(1) DESCRIPTION, --suffix |
| all four | default template | With no template, Solnix uses tmp.XXXXXX (six Xs) and implies -t. Linux and OpenBSD use tmp.XXXXXXXXXX (ten Xs). Linux implies --tmpdir. FreeBSD acts as if -t tmp was given. NetBSD acts as if -t mktemp was given.Source: Solnix mktemp(1) OPERANDS; Linux mktemp(1) DESCRIPTION; OpenBSD mktemp(1) DESCRIPTION; FreeBSD mktemp(1) DESCRIPTION; NetBSD mktemp(1) DESCRIPTION |
| FreeBSD, NetBSD | multiple templates | Solnix takes at most one optional template. FreeBSD and NetBSD synopses accept `template ...` and can create several files in one call. FreeBSD also allows this together with -t.Source: Solnix mktemp(1) SYNOPSIS; FreeBSD mktemp(1) SYNOPSIS, DESCRIPTION; NetBSD mktemp(1) SYNOPSIS, DESCRIPTION |
| NetBSD | -p and TMPDIR precedence | On Solnix, -p implies -t and a set TMPDIR overrides the -p directory. On NetBSD, -p applies to every file, and for -t it comes before TMPDIR. Without -p, a NetBSD template argument is relative to the current directory.Source: Solnix mktemp(1) -p, -t; NetBSD mktemp(1) -p tmpdir, -t prefix |
| Linux | -p and -t semantics | Linux -p DIR (or --tmpdir) interprets TEMPLATE relative to DIR, and the template may contain slashes. Linux marks -t deprecated. On Solnix, -p implies -t, so the template should contain no slashes. The Linux page does not say TMPDIR overrides -p.Source: Solnix mktemp(1) -p, -t; Linux mktemp(1) -p, --tmpdir, -t |
| FreeBSD | -p semantics | FreeBSD -p tmpdir is used for -t only when TMPDIR is unset, and also makes template arguments relative to tmpdir. An empty or omitted tmpdir means use TMPDIR. Solnix -p only supplies a prefix directory for -t mode.Source: Solnix mktemp(1) -p; FreeBSD mktemp(1) -p tmpdir, --tmpdir |
| FreeBSD, OpenBSD, NetBSD | exit status | Solnix documents exit 0 on success and 1 on error. FreeBSD and OpenBSD document 0 on success and >0 on error. NetBSD documents 1 on any failure. The Linux page documents no exit status. Source: Solnix mktemp(1) EXIT STATUS; FreeBSD mktemp(1) EXIT STATUS; OpenBSD mktemp(1) EXIT STATUS; NetBSD mktemp(1) EXIT STATUS |
| Linux | file mode | Solnix creates the file readable and writable only by its owner. Linux creates files u+rw and directories u+rwx, minus umask restrictions. The Solnix page does not mention the umask. Source: Solnix mktemp(1) DESCRIPTION; Linux mktemp(1) DESCRIPTION |
Standards
- POSIX: mktemp is not a POSIX.1-2024 utility.
- Solnix: Interface Stability: Committed.
Writing portable scripts
- Always pass a full template ending in Xs, such as `mktemp "${TMPDIR:-/tmp}/prog.XXXXXX"`. Avoid `
-tprefix`, which is a flag on Solnix and OpenBSD but takes an argument on FreeBSD and NetBSD. - Do not use
-uor--dry-runto get a name safely. It creates nothing on Linux but creates then unlinks on the other systems.
Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.