uname command in linux

Learn via video courses
Topics Covered

Overview

The uname command in Linux is an essential command-line utility that is used to fetch various system-related information. When used without any arguments the uname command will display the kernel name of the system. It can be used with its several options to retrieve various system information such as kernel name, processor type, hostname, kernel release number, etc. This makes it a fairly useful tool in a system administrator or developer's toolkit.

Introduction to Uname Command in Linux

The uname command is a Linux utility that is used to obtain information about the system and the hardware it is running on. The name "uname" stands for "Unix name," as the command was originally designed for Unix-based systems, although it is now commonly used in Linux-based systems as well. A uname command is a powerful tool for system administrators and developers, as it can be used to quickly obtain information about the system. It can be used to display information about the operating system, including the kernel version, machine hardware name, processor architecture, operating system name, and more.

Linux Uname Command Syntax

The syntax for the uname command in Linux is as follows:

Here, options are arguments that are used to specify which type of information is to be displayed. There are several options available with the uname command, which we will go through below.

Uname Command Options

The uname command in Linux comes with several options which allow us to modify its behavior as required. Some of the most commonly used options include-

OptionsDescription
-aThe -a option is used with the uname command to display all the available information about the system including kernel name, network node hostname, kernel release, kernel version, machine hardware name, processor type, hardware platform, and operating system name.
-nThe -n option is used with the uname command to retrieve the hostname of the system, which is the name given to the computer or device on a network.
-mThe -m option is used with the uname command to display the machine or processor type of the system. This option returns the type of hardware architecture that the Linux kernel is currently running on.
-rThe -r option is used with the uname command to retrieve the kernel release number, which is a unique identifier that is assigned to each kernel version.
-pThe -p option is used with The uname command to display the processor's architecture.
-sThe -s option is used with the uname command to display the kernel name of the operating system.

Uname Command in Linux With Examples

To gain a better understanding of the uname command, let's check out a few examples of the uname command along with its various options.

To Display The Complete System Name And Version Banner

In this example, we will see how we can use the uname command to display the complete system name and version banner. Example

Output display-complete-system-name Here, the uname command is used with the -a option, which displays all the available information about the system including the system name and version banner.

Running The Uname Command Without Any Options

Let us see in this example, how the uname command works without any arguments. Example

Output Uname Commands In the above output, we can see that, when the uname command is run without any arguments, the kernel name is displayed.

Using The Uname Command With -n Option

In this example, we will see how the uname command works with the -n option. Example

Output n Option In the above output, we can see that using the -n option with the uname command displays the hostname of the system.

Using The Uname Command With -m Option

In this example, we will understand how the uname command works when used with the -m option. Example

Output m Option When the uname command is used with the -m option, it displays the machine hardware name, which identifies the type of processor that the system uses. In the above output, we can see the returned value is "x86_64". This indicates that the system is using an x86 64-bit processor.

Using The Uname Command with -r Option

In this example, we will see how the uname command works with the -r option. Example

Output r Option

In the above output, we can see that the uname command when used with the -r option, displays the kernel release number,

Displaying The Architecture of The Processor Using -p Option

In this example, we will understand how to display the architecture of the processor using the uname option. Example

Output p Option

To display the architecture of the processor we can use the -p option as shown in the example above.

Conclusion

  • The uname command can be used to obtain information about the operating system and hardware on which it is running.
  • The uname command in Linux when used without any arguments, will return the kernel name.
  • There are several options available with the uname command, each of which displays a different set of system information.
  • Overall, the uname command is useful for system administrators in diagnosing issues, and for developers in cross-platform development and optimization.