uname Linux Command with Examples

February 14, 2023

Introduction

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.

uname command in Liux

Prerequisites

  • A system running Linux. (This tutorial uses Ubuntu 22.04.)
  • Access to the terminal.

uname Command Syntax

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
uname terminal output

However, using the uname command with specific options provides a more detailed output.

uname Command Options

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 --allPrints all system information.
-s--kernel-namePrints the Kernel name.
-n --nodenamePrints the network node hostname.
-r --kernel-releasePrints the Kernel release number.
-v --kernel-versionPrints the Kernel version.
-m --machineOutputs the machine's architecture type.
-p--processorPrints the CPU type.
-i --hardware-platformPrints hardware platform type.
-o --operating-systemPrints the operating system name.
n/a--helpDisplay a list of all available options.

uname Command Examples

The uname command works with one or more arguments to show different system information. The following sections provide practical examples for the uname command.

Show All System Info

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
uname a terminal output

The output includes the following information:

  • Kernel name: Linux.
  • Hostname: sara-pnap.
  • Kernel release: 5.15.0-58-generic.
  • Kernel version and the build date: #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023.
  • Machine architecture name: x86_64.
  • CPU type: x86_64.
  • Hardware platform: x86_64.
  • Operating system: GNU/Linux.

Print the Kernel Release Number

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
uname -r terminal output

Check Kernel Version

To check the system's Kernel version, run uname -v:

uname -v
uname -v terminal output

The uname -v output provides more details about the Kernel than the uname -r command. The output includes:

  • Kernel build number: #64.
  • The specific release of the kernel software. In this case, a version of Ubuntu - 20.04.1.
  • The OS name: Ubuntu.
  • An indicator that the Kernel is designed to run on a computer with multiple processors: SMP (Symmetric Multi-Processing).
  • The date and time when the Kernel was built: Fri Jan 6 16:42:31 UTC 2023.

Print System Hostname

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
uname -n terminal output

Note: The hostname command prints the same output.

Display Hardware Architecture

The uname -m command prints the machine's hardware architecture:

uname -m
uname -m terminal output

The -m option helps understand the system's underlying architecture.

Print CPU Type

The uname -p option displays the systems' processor type, which includes information about the system's architecture.

uname -p
uname -p terminal output

Print Hardware Platform Type

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
uname -i terminal output

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.

Print Operating System Name

Use uname -o to print the OS name:

uname -o
uname -o terminal output

Combining Command Options

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
uname -r -v terminal output

To print the Kernel name as well, run:

uname -srv
uname -srv terminal output

Conclusion

After reading this article, you should know how the uname command in Linux works.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How to Build Linux Kernel From Scratch {Step-By-Step Guide}
November 12, 2020

All Linux distributions come with a predefined kernel. However, they are usually outdated...
Read more
x64 vs. x86: Key Differences
July 20, 2022

This article shows an overview of the key features and differences between the two instruction set architecture types - x86 and x64. Check out the...
Read more
How to Check CPU Utilization in Linux with Command Line
January 31, 2019

See how to check CPU processor usage to ensure the best system performance...
Read more
Linux Commands All Users Should Know {Ultimate List}
October 4, 2022

This article contains a list of commands all Linux users should know. Whether...
Read more