The uname
(UNIX name) command in Linux is a simple yet powerful tool that offers information about a Linux machine’s operating system and hardware platform. Sysadmins and developers use uname
for troubleshooting and monitoring purposes.
This article provides a comprehensive guide on the uname
command in Linux and its various options.
Prerequisites
The uname
command uses the following basic syntax:
uname [option1] [option2]
When run without any options, uname
prints the Kernel name, the same as using the -s
option.
uname
However, using the uname
command with specific options provides a more detailed output.
Options modify the command output by printing specific information, such as the hostname, Kernel release number and version, machine architecture, etc.
The table below is a complete list of the available uname
command options and their descriptions:
Option (Short Form) | Option (Long Form) | Desription |
---|---|---|
-a |
--all |
Prints all system information. |
-s |
--kernel-name |
Prints the Kernel name. |
-n |
--nodename |
Prints the network node hostname. |
-r |
--kernel-release |
Prints the Kernel release number. |
-v |
--kernel-version |
Prints the Kernel version. |
-m |
--machine |
Outputs the machine’s architecture type. |
-p |
--processor |
Prints the CPU type. |
-i |
--hardware-platform |
Prints hardware platform type. |
-o |
--operating-system |
Prints the operating system name. |
n/a | --help |
Display a list of all available options. |
The uname
command works with one or more arguments to show different system information. The following sections provide practical examples for the uname
command.
The uname
command with the -a
argument prints all relevant system information. This is how sysadmins usually use the command to get all relevant information with one request.
uname ˗a
The output includes the following information:
The uname ˗a
command’s output is extensive but disorganized and difficult to read. To show specific details about the system, use uname
with different arguments.
For instance, to display only the Kernel release number, use uname -r
:
uname -r
To check the system’s Kernel version, run uname -v
:
uname -v
The uname -v
output provides more details about the Kernel than the uname -r
command. The output includes:
Use uname -n
to print the system’s hostname. The hostname is a unique name assigned to a computer in a network and used to identify it.
uname -n
Note: The hostname command prints the same output.
The uname -m
command prints the machine’s hardware architecture:
uname -m
The -m
option helps understand the system’s underlying architecture.
The uname -p
option displays the systems’ processor type, which includes information about the system’s architecture.
uname -p
Print the hardware platform type with uname -i
. The hardware platform provides information about the type of hardware the system is running on.
uname -i
Note: The -m
, -p
, -i
arguments often print the same output because these options provide information about the hardware’s architecture. However, the specific information each option offers depends on the OS in use.
Use uname -o
to print the OS name:
uname -o
Use several uname
options to get a specific combination of system information. For example, to display the Kernel’s release number and build date, use the -r
and -v
options:
uname -r -v
To print the Kernel name as well, run:
uname -srv
After reading this article, you should know how the uname
command in Linux works.