The uname command in Linux is used to display system information. It provides details about the operating system, kernel version, and other system-specific data. Let’s break down its functionality and provide some examples.
Options
Here are some commonly used options with uname:
Short options | Long options | meaning |
---|---|---|
-a | –all | Displays the kernel name (-s), hostname (-n), kernel release number (-r), kernel version (-v), hardware name (-m), CPU (-p, omitted if unknown), hardware platform (-i, omitted if unknown), and OS name (-o), in that order. |
-s | –kernel-name | Show kernel name (default) |
-n | –nodename | Show hostname (network node) |
-r | –kernel-release | Print the kernel release number |
-v | –kernel-version | Show kernel version |
-m | –machine | Show hardware name (e.g. x86_64) |
-p | –processor | Show CPU type (or “unknown” if unknown) |
-i | –hardware-platform | Show the hardware platform (or “unknown” if unknown) |
-o | –operating-system | Show the name of the OS |
Examples
Print the Kernel Name:
Print the Network Node Hostname:
uname -n Output localhost
Print the Kernel Release:
uname -r Output: 6.6.9-amd64
Print the Kernel Version:
uname -v Output: #1 SMP PREEMPT_DYNAMIC Kali 6.6.9-1kali1 (2024-01-08)
Print the Machine Hardware Name:
Print the Processor Type (might be unknown on some systems):
Print the Hardware Platform (might be unknown on some systems):
Print the Operating System:
uname -o Output: GNU/Linux
Print All System Information:
uname -a Output: Linux localhost 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Explanation of Output
- Linux: The kernel name.
- localhost: The network node hostname.
- 5.4.0-42-generic: The kernel release version.
- #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020: The kernel version, including build and compiler info.
- x86_64: The machine hardware name, processor type, and hardware platform (all are the same in this example).
- GNU/Linux: The operating system name.
Summary
The uname
command is a versatile tool to quickly gather system information, particularly useful in scripting and system administration tasks. By using the appropriate options, you can specify exactly what information you need, or use -a
to get a comprehensive overview of the system.