This guide will show you how to use the uname command on your Linux system.
uname is short for Unix name and is a program used to print various information about the current operating system. It is a utility made available on both Linux and Unix-like systems such as Linux.
You can print various details using the uname commands various options, including the kernel name, system architecture, and more.
Within this guide we will teach you the various ways to utilize this helpful tool on your Linux operating system.
Table of Contents
- Syntax for the uname Command
- Printing the Kernel Name
- Getting the Kernel Release
- Retrieving the Kernel Version
- Getting the hostname Using uname
- Retrieve the Machine Name
- Print the Processor Type
- Getting the Hardware Platform
- Retrieve the Operating System Name
- Print All Results of the uname Command
Syntax for the uname Command
uname command has a straightforward syntax, having only a single parameter.
While the “
[OPTIONS]” parameter is optional, it is crucial to get this tool to print out additional information. By default, the utility will only provide the kernel name.
In the following sections, we will explore the various options that you can use to modify the output of the command.
Printing the Kernel Name using the uname Command
We can use the “
-s” or “
--kernel-name” option alongside the uname command to print out the kernel name.
This tool will simply return “
Linux” on most Linux-based operating systems.
To test this on your current system, you can run the following command in the terminal.
By using this option you will get a simple response like the following.
Using the uname Command to Get the Kernel Release
One of the most valuable features of the uname command is its ability to print the current kernel release. The kernel release string indicates what version of the Linux kernel you are using.
To achieve this, you can use the “
-r” or “
--kernel-release” option to tell the tool to print the release name.
For example, if we used the command above, you would end up with a result like we have shown below.
Retrieving the Kernel Version
We can also use the uname command to retrieve the kernel version. The kernel version tells you exactly when the kernel itself was compiled.
You will need to use the “
-v” or “
--kernel-version” option to get the kernel version.
Below is an example of what you will retrieve by running this command. From this command, we can see that the kernel on our system was compiled on November 18th, 2021.
#1488 SMP Thu Nov 18 16:15:28 GMT 2021
Using uname to Get the Hostname
You can also use the uname command to retrieve and print your device’s hostname. This utility describes this result as the “network node hostname”.
On Linux, the hostname command even makes an internal call to uname to get the hostname.
To use uname to retrieve the hostname, you need to use the “
-n” or “
After using this command, you will get a result like shown below.
Using the uname Command to Retrieve the Machine Name
Using the uname command. you can retrieve the machine hardware name for your current device. On a Linux system, this is typically the kernel’s architecture.
To retrieve the machine hardware name, you will need to use the “
-m” or “
Using this option with the uname command will get a result like the following.
From this result, we can tell that we are running an ARM operating system. If you are using a 64-bit system, you will see text like “
x86_x64” or for a 32-bit system you might see “
Print the Processor Type from uname
Using the uname command, you can also print the processor type to the command line. The processor type typically reflects the architecture of your CPU. However, not all versions of the Linux kernel support this functionality.
To retrieve the processor type, use the option “
-p” or “
--processor” alongside “
On a system that provides the required information for uname, you will see your CPUs architecture.
However, if the Linux kernel does not implement this required functionality, you will get a result as we have shown below.
Getting the Hardware Platform using the uname Command
We can also utilize this utility to retrieve the hardware platform. The hardware platform is the architecture that the software itself was compiled for. Like the processor type, not all Linux kernels provide this version.
You will need to use the “
-i” or “
--hardware-platform” option alongside the uname command to get the hardware platform.
When running an operating system that reveals this information, you should see the architecture the software was built for.
If the functionality isn’t implemented, you will get a result like the following. It shows that the uname command can’t find the information it requires.
Retrieve the Operating System Name
You can also use the uname command to print the operating system name. With the way the Linux kernel implements this, the result will always be “
To retrieve the operating system name, you can use the “
-o” or “
If you use this command on a Linux operating system, you will likely get the following result.
Print all Results from the uname Command
The utility can even print all of the information we discussed previously by using a single option.
To get the uname command to print out all of its available information, you need to use the “
-a” or “
After using the preceding command, you will get a result like the following.
Linux pimylifeup 5.10.63-v7l+ #1488 SMP Thu Nov 18 16:15:28 GMT 2021 armv7l GNU/Linux
The results that we have shown you above uses the following ordering:
- Kernel Name
- Nodename (Hostname)
- Kernel Release
- Kernel Version
- Machine Hardware Name
- Processor Type (Will only prin, if available)
- Hardware Platform (Will only print if available)
- Operating System Name
You should now have a good idea of how you can use the uname command on your Linux system.
This tool helps find various pieces of information from your system. The details can range from the device’s kernel name to the processor type.
If you have had any issues using this command, please comment below.
Check out our various other Linux tutorials or command guides. These guides will help you better understand how best to use a Linux-based system.