How to use the uname Command on Linux

This guide will show you how to use the uname command on your Linux system.

uname command on linux

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

The uname command has a straightforward syntax, having only a single parameter.

uname [OPTIONS]

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.

uname -s

By using this option you will get a simple response like the following.

Linux

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.

uname -r

For example, if we used the command above, you would end up with a result like we have shown below.

5.10.63-v7l+

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.

uname -v

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 “--nodename” option.

uname -n

After using this command, you will get a result like shown below.

pimylifeup

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 “--machine” option.

uname -m

Using this option with the uname command will get a result like the following.

arm7l

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 “i386“.

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 “uname“.

uname -p

On a system that provides the required information for uname, you will see your CPUs architecture.

x86_x64

However, if the Linux kernel does not implement this required functionality, you will get a result as we have shown below.

unknown

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.

uname -i

When running an operating system that reveals this information, you should see the architecture the software was built for.

x86_64

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.

unknown

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 “GNU/Linux“.

To retrieve the operating system name, you can use the “-o” or “--operating-system” options.

uname -o

If you use this command on a Linux operating system, you will likely get the following result.

GNU/Linux

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 “--all” option.

uname -a

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:

  1. Kernel Name
  2. Nodename (Hostname)
  3. Kernel Release
  4. Kernel Version
  5. Machine Hardware Name
  6. Processor Type (Will only prin, if available)
  7. Hardware Platform (Will only print if available)
  8. Operating System Name

Conclusion

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.

Leave a Reply

Your email address will not be published. Required fields are marked *