Date
Nov. 21st, 2024
 
2024年 10月 21日

Post: Using uname command in Linux [Output Explained]

Using uname command in Linux [Output Explained]

Published 21:11 Nov 20, 2023.

Created by @ezra. Categorized in #UNIX/Linux, and tagged as #UNIX/Linux.

Source format: Asciidoc

Table of Content

The uname stands for Unix Name and this useful command provides users with important system information.

In this quick tutorial, I’ll show what kind of information you can get about your system with the uname command.

Using the uname command on Linux

There are several options that can filter out the specific information you need.

uname [options]

This command is really self-explanatory, so I will list the possible options and the description of their output.

Then I will go through each on my machine and display the output. Feel free to follow along.

The uname command Options

Function Shortcut

Kernel Name

\-s

Kernel Release

\-r

Kernel Version\*

\-v

Network Node Name (Hostname)

\-n

Machine architecture

\-m

Processor architecture

\-p

Hardware Platform (OS architecture)

\-i

Operating System

\-o

The uname command output

I’ve called each option to show you the output on my system.

ezra@pop-os:~$ uname -s
Linux

ezra@pop-os:~$ uname -r
5.3.0-22-generic

ezra@pop-os:~$ uname -v
#24+system76~1573659475~19.04~26b2022-Ubuntu SMP Wed Nov 13 20:0

ezra@pop-os:~$ uname -n
kubuntu

ezra@pop-os:~$ uname -m
x86_64

ezra@pop-os:~$ uname -p
x86_64

ezra@pop-os:~$ uname -i
x86_64

ezra@pop-os:~$ uname -o
GNU/Linux

The output for -m,-p, and -i is the same on my system but these values don’t reference the same piece of information. If it was a 32-bit system, the output would be different.

You might also get different output if you are using a virtual machine. One one of mine, -p and -i return “unknown”.

Here’s an example using an old Ubuntu VM.

ezra@ubuntu: ~$ uname -p
unknown
ezra@ubuntu: ~$ uname -i
unknown

Put it all together with uname -a

There is one more option. What if you just want a single string with all of this info? Yup, you can do that with -a!

Here’s the result of uname -a command:

ezra@pop-os:~$ uname -a
Linux pop-os 5.3.0-22-generic #24+system76~1573659475~19.04~26b2022-Ubuntu SMP Wed Nov 13 20:0 x86_64 x86_64 x86_64 GNU/Linux

Let’s break down the output one more time:

  • Linux – OS kernel name

  • pop-os – hostname

  • 5.3.0-22-generic – kernel release

  • #24+system76~1573659475~19.04~26b2022-Ubuntu SMP Wed Nov 13 20:0 – details about the last time the kernel was compiled

  • x86_64 – Machine architecture

  • x86_64 – Your processor architecture (x86_64 means 64 bit)

  • x86_64 – Your operating system’s architecture

  • GNU/Linux – Your operating system

You may have this information available in different locations via the GUI, but nothing really beats the speed and ease of this simple command.

Now let me show you the most useful examples of this command.

Get the kernel version with uname -r

You can get the Linux kernel version information with the -r option:

ezra@pop-os:~$ uname -r
5.3.0-22-generic

Get the hostname with uname -n

There are ways to get the hostname in Linux. One of them is using the -n option of the uname command:

ezra@pop-os:~$ uname -n
kubuntu

Get processor architecture (32-bit or 64-bit)

While you don’t get detailed CPU info in Linux with uname, but you can surely find out if your CPU is 32 bit or 64 bit with the -p option.

ezra@pop-os:~$ uname -p
x86_64

x86_64 means 64-bit. i686, i386 etc means 32-bit.

Get operating system architecture (32-bit or 64-bit)

You can install 32-bit OS on a 64-bit CPU. So to find out the architecture of your OS, use -i option:

ezra@pop-os:~$ uname -i
x86_64

You can of course utilize the rest of the uname option if the need be.

Conclusion

The unix name utility is particularly helpful when troubleshooting. Many times this will be one of the first things requested by a support team. Knowing the kernel version, OS, and basic hardware information is important to figuring out why a piece of software is not performing as expected.

By the way, if you want to know which Linux distribution you are using, just look into the content of the /etc/os-release file.

I hope you now know how to use the uname command in Linux. If you have questions or suggestions, please let me know.

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询