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.
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
|Network Node Name (Hostname)||-n|
|Hardware Platform (OS architecture)||-i|
The uname command output
I’ve called each option to show you the output on my system.
[email protected]:~$ uname -s Linux [email protected]:~$ uname -r 5.3.0-22-generic [email protected]:~$ uname -v #24+system76~1573659475~19.04~26b2022-Ubuntu SMP Wed Nov 13 20:0 c[email protected]:~$ uname -n linuxhandbook [email protected]:~$ uname -m x86_64 [email protected]:~$ uname -p x86_64 [email protected]:~$ uname -i x86_64 [email protected]:~$ 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.
[email protected]: ~$ uname -p unknown [email protected]: ~$ 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:
[email protected]:~$ 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:
[email protected]:~$ 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:
[email protected]:~$ uname -n linuxhandbook
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.
[email protected]:~$ 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:
[email protected]:~$ uname -i x86_64
You can of course utilize the rest of the uname option if the need be.
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.
I hope you now know how to use the uname command in Linux. If you have questions or suggestions, please let me know.