UNAME(1) General Commands Manual UNAME(1)

uname, machine, archget system information

uname [-asnrvmpio]
machine
arch

Writes some system information to the standard output stream in the order listed below, separated by spaces. Except where otherwise specified, information is obtained using uname(2), and is beholden to drawbacks thereof.

For uname, the default is -s. machine and arch are equivalent to uname -m.

Parenthesised are fields of struct utsname returned by uname(2).

, --all
Write all fields, only write -pi if not "unknown".
, --kernel-name
Name of the kernel (sysname).
, --nodename
Name of system on some communcation network, which usually means the configured hostname (nodename).
, --kernel-release
Kernel version (release).
, --kernel-version
Extended human-readable (version).
, --machine
Kernel processor target (machine).
, --processor
Current processor architecture. hw.machine_arch sysctl on NetBSD, FreeBSD, and DragonFly, the MACHINE_ARCH macro on OpenBSD, sysinfo(SI_ARCHITECTURE) on the illumos gate, and "unknown" elsewhere.
, --hardware-platform
sysinfo(SI_PLATFORM) on the illumos gate; "unknown" elsewhere.
, --operating-system
Same string as -s.

uname(2)

uname conforms to IEEE Std 1003.2-1992 (“POSIX.2”). -p is an extension, originating from AT&T System V Release 4 UNIX. -i is an extension, originating from SunOS 5 (Solaris 2). -o is an extension, originating from the GNU system.

-a is allowed to write any extra fields after the mandated -mnrsv. This implementation mimicks the GNU system by writing -pi, if not "unknown", then -o (GNU system -o is a mangled -s).

arch is compatible with SunOS 3 (but not SunOS 4 (Solaris) and later) and the GNU system, but not OpenBSD. machine is compatible with 4.4BSD (OpenBSD (sans -a), NetBSD).

Appears in the Programmer's Workbench (PWB/UNIX) User's manual as uname(I):

uname - print name of current UNIX
"mainly useful to determine what system one is using", writing out uname(II):
uname - get name of current PWB/UNIX
with a DESCRIPTION of
Uname returns in name the 8 byte character name of the current PWB/UNIX. The name is not null-terminated. By convention, the name is of the form pwb?date. For example, pwba0401 would indicate that this is PWB/UNIX System A and that its operating system was last modified on April 1.

AT&T System III UNIX inherits them in an almost-present-day -asnrv (default -s) and struct utsname with sysname, nodename, release, version, all 8 characters + NUL long, with uname(2) just copying utsname with strings defined at build time.

AT&T System V Release 1 UNIX adds -m and the corresponding struct utsname machine member.

SunOS 3 ships arch and mach scripts, writing [] and [], respectively, if the corresponding programs return successfully (i.e. on a sun3 system, /bin/sun3 is linked to /bin/true and sun2 to false, likewise for the architecture).

The "System V programs and libraries" optional package contains AT&T System V Release 1 UNIX uname(1V) and uname(2V).

AT&T System V Release 3 UNIX adds uname -S system name, only on the 3B2, validating the argument length and setting sysname and nodename thereto, and updating the NVRAM if available (with the kernel similarly reading it back from the NVRAM on boot).

AT&T System V Release 4 UNIX adds -p (included in -a), writing out sysinfo(SI_ARCHITECTURE) of "386/MB1", "386/MB2", or "386/AT" as a fallback, contrasting with -m (always "i386"), and extends the member lengths to characters + NUL "to support Internet hostnames". This is papered over in userspace, defaulting to the larger fields, unless compatibility mode is requested. -S is extended to i386, the only official target platform, but since i386 doesn't have non-volatile RAM (and the 3B2 only has 8 bytes' worth), it's stored, if changed, in /etc/nodename (and on i386 the /etc/rc2.d/S11uname init-script calling uname -S is created) before being set for the current system.

A setuname [-t] [-s name] [-n node] command is also provided (with at least one of -sn required) setting the sysname and nodename separately (and validating both the length and domain to alphanumerics plus {‘-’, ‘_’}) by:

  • writing them directly to kernel address space;
  • writing the /etc/rc2.d/S18setuname init-script ("setuname -s name|sysname -n node|nodename"), unless -t is specified;
  • committing sysname to /etc/systemid, if changed;
  • committing nodename to /etc/nodename, if changed.

It also ships arch and mach in /usr/ucb for "compatibility with the SunOS command"s, just runnng uname -m and uname -p, respectively. It is therefore likely that -p appeared as a reasonable alternative to shipping another (hostid(1)) single-puts(3) program.

SunOS 4 (Solaris) mach is largely equivalent methodologically to SunOS 3's, but across , , , and , and writes "unknown" if none of the above match. arch, however, grows -k, writing the "kernel architecture" (model), any of , sun3, , sun4, , and (or "unknown"), but writes the "application architecture" by default — that being the same, but without the trailing letter (or "unknown"), in an unprecedented case of software compatibility forethought. It may instead take archname, exiting successfully if archname is the same as the current "application architecture".

SunOS 5 (Solaris 2), now based on AT&T System V Release 4 UNIX, inherits its uname (sans platform-specific cases, with -S system_name available everywhere, no init-script, and setting just the hostname (nodename) the via the usual sysinfo(SI_SET_HOSTNAME)) adding -i (included in -a) for sysinfo(SI_PLATFORM).

setuname, following the removal of uname's init-script, writes its init-script with -t, doesn't read it back, and only specifies -s name in it, writing the -n node argument, if any, to /etc/nodename, which is the normal location /etc/init.d/rootusr reads and passes to uname -S, before falling back to network (the default being the empty string).

Indeed, it's very odd sysname was ever settable at all, more so still that it was the expected default when setting the hostname.

Likewise, mach is just uname -p. arch "kernel architecture" is just uname -m but the "application architecture" is the same, except on sun4-family systems where it's sun4.

SunOS 5.7 (Solaris 7) adds SCO UNIX compatibility -X flag to write, after the usual output (but before the newline):

System = sysname
Node = nodename
Release = release
KernelID = version
Machine = machine
BusType = <unknown>
Serial = <unknown>
Users = <unknown>
OEM# = 0
Origin# = 1
NumCPU = sysconf(_SC_NPROCESSORS_CONF)
It also includes a SCO UNIX compatibility compilation mode that splits the SYSV3 environment variable on commas (‘’), ignoring the first entry (supposedly the "OS" field), copying consecutive fields into the output (or, if set but empty, using the "reasonable default" of sysname = nodename, release = "3.2", version = "2", machine = "i386") and removing -ip from -a if set. Thankfully, the latter does not remain in the illumos gate.

SunOS 5.8 (Solaris 8) uname -S no longer writes /etc/nodename.

4.3BSD-Reno includes machine, puts()ing MACHINE, matching the source name for the architecture (, , ).

4.4BSD obsoletes it with uname -m, providing a shell wrapper doing exactly that; the uname implementation is exactly standard, and uname(3) reads {CTL_KERN, KERN_OSTYPE} ("kern.ostype"), {CTL_KERN, KERN_HOSTNAME} ("kern.hostname"), {CTL_KERN, KERN_OSRELEASE} ("kern.osrelease"), {CTL_KERN, KERN_VERSION} ("kern.version") (with newlines and tabs replaced with spaces, a NUL if at the end), and {CTL_HW, HW_MACHINE} ("hw.machine") sysctls. All of these, save for the hostname, are unsettable, and the kern tree ones generated as part of the kernel build.

NetBSD 1.4 adds -p (not included in -a) "inspired by SunOS 5", {CTL_HW, HW_MACHINE_ARCH} ("hw.machine_arch"), returning the precise architecture, in contrast to -m's port name.

OpenBSD 1.2 adds arch [-k] (quoting SunOS for the latter), writing the "application architecture" ("kernel architecture" with -k) — this time defined as a "sysname.MACHINE_ARCH" ("sysname.MACHINE" with -k) tuple.

OpenBSD 2.3 adds -p (not included in -a) writing "the processor type in more detail" — {CTL_HW, HW_MODEL} ("hw.model"). This, being the precise CPU model (in some cases the marketing name, in others the ID + revision, sometimes the frequency, &c.) is of course incompatible with all other -p implementations.

OpenBSD 2.6 merges machine into arch (no output changes), adding -a (to write MACHINE_ARCH) instead. arch itself grows -s (removing the OpenBSD. prefix, now literal).

OpenBSD 5.0 changes its -p to the current MACHINE_ARCH for compatibility.

FreeBSD 2.0 removes machine.

FreeBSD 3.0 adds -p as an alias for -m, quoting AT&T System V Release 4 UNIX compatibility.

FreeBSD 5.0 makes it a bespoke flag (not included in -a), equivalent to NetBSD's, and allows per-flag overrides via UNAME_flag environment variables. As part of that, it also replaces the uname(3) call with manual sysctl parsing, and breaks -v output by not truncating it if the final byte is a tab or newline; this is an obvious conformance bug, somehow unnoticed, reported and fixed in FreeBSD 13.1 by yours truly after 19 : #256486.

FreeBSD 5.2 adds -i (not included in -a), for {CTL_KERN, KERN_IDENT} ("kern.ident") — the kernel config filename/-type (GENERIC, MINIMAL, &c.).

FreeBSD 9.0 adds -o as an alias for -s "for compatibility with other systems", cf. the unfortunate case of -o in STANDARDS.

Many more flags appear in later FreeBSD releases.

uname() appears in System V Interface Definition: Issue 1 (“SVID”), with struct utsname members of size SYS_NMLN. X/Open Portability Guide (“XPG”) includes it verbatim.

uname appears in X/Open Portability Guide Issue 2 (“XPG2”), as present-day.

X/Open Portability Guide Issue 3 (“XPG3”) makes struct utsname member array lengths undefined and allows uname() to be a macro, as present-day.

April 24, 2023 voreutils pre-v0.0.0-latest