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.
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
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.
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
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.
unamedoes not tell you whether the system is Ubuntu or Fedora. Read/etc/os-release(. /etc/os-release; echo "$PRETTY_NAME") or runlsb_release -afor that. See alsohostnamectl. - 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 usesort -V. - Architecture names differ: Linux calls it
x86_64andaarch64, while Debian packages sayamd64andarm64, and Docker usesamd64/arm64. Map them in scripts, as the second example shows. On Debian-based systemsdpkg --print-architecturegives 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 -mreports the kernel's machine type, so a 32-bit program may seex86_64. Usegetconf LONG_BITfor the userland word size. - The host name from
uname -nis the same ashostname. - macOS and BSD also have
uname, withDarwinorFreeBSDas the kernel name; GNU-only options (-o) may be missing or different. - Portable options in POSIX are
-a -m -n -r -s -v;-o,-pand-iare GNU extensions.
Related
hostnamectl,hostname,lscpu,getconf- Lessons: Boot and kernel, Portability