Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท System Information

Linux uname command

Reference for the Linux uname command: print the kernel name, release, version, machine architecture and host name, with options -a, -r, -m, -s and script uses.

uname prints basic facts about the running system: the operating system kernel's name, its release number, the machine hardware type, and the host name. It is the quickest way to answer "which kernel is this?" and "is this a 64-bit Intel or an ARM machine?", and scripts use it to choose between platform-specific behavior.

Without options it prints only the kernel name, Linux. Each option adds one field, and -a prints all of them on one line.

Terminal
uname          # Linux
uname -r       # kernel release, for example 6.8.0-45-generic
uname -m       # architecture, for example x86_64 or aarch64
uname -a       # everything

Try it

Bash Individual fields

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Choosing a download by platform

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
uname [OPTION]...
Option Description
-s, --kernel-name Kernel name (Linux). This is the default.
-n, --nodename Network host name.
-r, --kernel-release Kernel release, such as 6.8.0-45-generic.
-v, --kernel-version Kernel build information, like #45-Ubuntu SMP ....
-m, --machine Hardware name: x86_64, aarch64, armv7l, riscv64.
-p, --processor Processor type; often prints unknown.
-i, --hardware-platform Hardware platform; often unknown.
-o, --operating-system Operating system, normally GNU/Linux.
-a, --all All of the above (omitting -p and -i when they are unknown).

Returns: 0 on success. Fields are always printed in the same order (-s -n -r -v -m -p -i -o), whatever order you type the options.

Usage notes

  • Kernel, not distribution. uname does not tell you whether the system is Ubuntu or Fedora. Read /etc/os-release (. /etc/os-release; echo "$PRETTY_NAME") or run lsb_release -a for that. See also hostnamectl.
  • Release number: it has the shape MAJOR.MINOR.PATCH-extra. To compare versions in a script, strip the suffix: uname -r | cut -d- -f1, and use sort -V.
  • Architecture names differ: Linux calls it x86_64 and aarch64, while Debian packages say amd64 and arm64, and Docker uses amd64/arm64. Map them in scripts, as the second example shows. On Debian-based systems dpkg --print-architecture gives the package name directly.
  • Containers show the host kernel. A Debian container on an Ubuntu host reports the host's kernel release, because containers share the kernel.
  • 32-bit userland on a 64-bit kernel: uname -m reports the kernel's machine type, so a 32-bit program may see x86_64. Use getconf LONG_BIT for the userland word size.
  • The host name from uname -n is the same as hostname.
  • macOS and BSD also have uname, with Darwin or FreeBSD as the kernel name; GNU-only options (-o) may be missing or different.
  • Portable options in POSIX are -a -m -n -r -s -v; -o, -p and -i are GNU extensions.