Sometimes, you might need to quickly find out things like the name of the kernel, its version, the hostname name, and more on your Linux system/server. While you can search for this information in specific files stored in the proc system, it's simpler to use a tool called uname to get these details fast.
The uname is a tool you can use on the command line to find out what type of processor your computer has, its name, and what version of the core software it's running.
Syntax:
uname [OPTION]...
Options
Here are different options you can use with a command:
-a or --all: Shows all the information in a specific order, but doesn't include certain details if they're not known.
-s or --kernel-name: Displays the name of the core software.
-n or --nodename: Reveals the computer's network node name.
-r or --kernel-release: Presents the release version of the core software.
-v or --kernel-version: Shows the version of the core software.
-m or --machine: Gives the name of the hardware your computer uses.
-p or --processor: Displays the type of processor (not always available).
-i or --hardware-platform: Reveals the hardware platform (not always available).
-o or --operating-system: Shows the operating system.
--help: Provides information about how to use the command.
--version: Displays the version information of the command.
Examples
Let's check out some examples that show how to use the 'uname' command.
'uname' without any option
When you run the 'uname' command without any extra instructions, it only tells you the name of the core software. In the following example, you can see that the system uses the 'Linux' core software:
Command:
$ uname
Output:
Linux

You can also use 'uname -s' to see the same kernel name:
Command:
$ uname -s
Output:
Linux

Getting the network node host name using the '-n' option
To find out the network node host name of your Linux system, use 'uname -n':
Command:
$ uname -n
Output:
server155.com

The output here is the same as what you'd get from the 'hostname' command.
Get kernel release using -r option:
To find the version of the core software, use 'uname -r':
Command:
$ uname -r
Output:
5.4.0-155-generic

Get the kernel version using -v option:
To get the version of the core software, use 'uname -v':
Command:
$ uname -v
Output:
#172-Ubuntu SMP Fri Jul 7 16:10:02 UTC 2023
Get the machine hardware name using -m option:
To know the name of your computer's hardware, use 'uname -m'. If it shows 'x86_64', it means it's a 64-bit system:
Command:
$ uname -m
Output:
x86_64

Get the processor type using -p option:
To get the processor type, use 'uname -p'. It might show 'unknown' if it can't find the information:
Command:
$ uname -p
Output:
x86_64

Get the hardware platform using -i option:
To learn about the hardware platform, use 'uname -i'. It could display 'unknown' if the information is missing:
Command:
$ uname -i
Output:
x86_64
Get the operating system name using -o option:
To get the name of the operating system, use 'uname -o':
Command:
$ uname -o
Output:
GNU/Linux
These options help you gather various details about your computer's software and hardware.

Get complete information using -a option:
You know, we've been figuring out different things using specific flags, right? Well, with 'uname -a', you can get all that information at once. This is done using the -a option. You can also pick multiple options, and the results will show up in a specific order for the options you chose.
Kernel name
Nodename/hostname
Kernel release
Kernel version
Machine
Processor
Hardware platform
Operating System
$ uname -a

Linux server155.com 5.4.0-155-generic #172-Ubuntu SMP Fri Jul 7 16:10:02 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Displayed output in the above example shows the following items:
Kernel name: Linux
Nodename/hostname: server155.com
Kernel release: 5.4.0-155-generic
Kernel version: #172-Ubuntu SMP Fri Jul 7 16:10:02 UTC 2023
Machine: x86_64
Processor: x86_64
Hardware platform: x86_64
Operating System: GNU/Linux
Conclusion:
In this guide, we've been exploring the uname command in Linux. It helps us get important details about our computer system. If you find it hard to remember or don't need some of the choices, just remember that using -a will give you everything. Then you can look through the short list of information to find what you want.


