Displaying and interpreting information about Linux versions is a little more complicated than it seems.
Instead of referring to a simple version number, there are many ways to identify Linux versions. Even a quick look at the output of the uname command can tell you something. What is that information? What does it tell you?
In this article, we’ll take a closer look at the output of the uname command and the versioning instructions provided by some of the other commands and files.
Using the uname
Whenever you run the command uname -a in a Linux terminal window, a lot of information is displayed. That’s because the little A tells the uname command that you want to see all the output the command can provide. What is displayed will tell you a lot about the system. In fact, each piece of information displayed tells you something different about the system.
For example, the uname -a output looks like this:
$ uname -aLinux dragonfly 5.4.0-37 - generic#41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Copy the code
Although this may not be important, you can display the same information with a single option that includes uname all in the proper order:
$ uname -snmrvpio
Linux dragonfly 5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Copy the code
To break this long list of information into separate chunks, use a for loop like this to iterate over each option:
$ for option in s n m r v p i o; do echo -n "$option:"; uname -$option; doneS: Linux n: Dragonfly M: x86_64 r: 5.4.0-37- Generic V:#41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020
p: x86_64
i: x86_64
o: GNU/Linux
Copy the code
The loop shows what information is provided by the option. The uname man page provides a description of each option. Here’s the list:
- Linux — kernel name (option
s
) - Dragonfly — node name (option
n
) - X86_64 — Machine hardware name (option)
m
) - 5.4.0-37- Generic — Kernel release version (option
r
) - #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 — Kernel version (option
v
) - X86_64 – – Processor (option
p
) - X86_64 – – Hardware platform (optional)
i
) - GNU/Linux — Operating system (options)
o
)
To delve more deeply into the information displayed, take a closer look at the kernel release data displayed. The 5.4.0-37 in line 4 is not just an arbitrary string of numbers. Every number counts.
5
Represents the kernel version4
Represents the major version0
Represents a minor version37
Indicates the latest patch
Also, #41 in line 5 (kernel version) of the output in the loop above means that this release has been compiled 41 times.
A single option can be useful if you want to display only one item of all information. For example, the command uname -n can tell you only the system name, and uname -r can tell you only the kernel release. These and other options can be useful when inventorying servers or building scripts.
On Red Hat systems, the uname -a command provides the same kind of information. Here’s an example:
$ uname -aLinux fruitfly 4.18.0-107. El8 x86_64#1 SMP Fri Jun 14 13:46:34 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Copy the code
Release information
If you need to know what distribution you’re running on, the output of UName won’t help you much. After all, kernel versions are different from distributions. For this information, you can use the lsb_release -r command on Ubuntu and other Debian-based systems, while on Red Hat you can display the contents of the /etc/Redhat-release file.
For Debian:
$lsb_release -r Release: 20.04Copy the code
For Red Hat and related systems:
$cat /etc/red Hat - Release Red Hat Enterprise Linux Release 8.1 Beta (Ootpa)Copy the code
Use the/proc/version
The /proc/version file can also provide information about Linux versions. The information provided in this file has much in common with the uname -a output. Here are some examples.
On Ubuntu:
$cat /proc/version Linux version 5.4.0-37-generic (buildd@lcy01-amd64-001) (GCC version 9.3.0 (Ubuntu 9.3.0-10ubuntu2))#41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020
Copy the code
On the RedHat:
$ cat /proc/version
Linux version 4.18.0-107.el8.x86_64 ([email protected]) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Fri Jun 14 13:46:34 UTC 2019
Copy the code
conclusion
Linux systems provide a lot of information about kernel and distribution installations. You just need to know where or how to look for and understand its meaning.
Via: www.networkworld.com/article/356…
Author: Sandra henry-stocker lujun9972
This article is originally compiled by LCTT and released in Linux China