translated

This commit is contained in:
geekpi 2020-07-14 08:46:59 +08:00
parent 5d298e84ce
commit 194a3ceb60
2 changed files with 142 additions and 142 deletions

View File

@ -1,142 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to decipher Linux release info)
[#]: via: (https://www.networkworld.com/article/3565432/how-to-decipher-linux-release-info.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
How to decipher Linux release info
======
Displaying and interpreting information about Linux releases is a bit more complicated than it might seem.
[christin hume / Linux / Modified by IDG Comm.][1] [(CC0)][2]
Theres a lot more to identifying a Linux release than citing a simple version number. Even a quick look at the output from the **uname** command can tell you that. What is all of that information, and what does it tell you?
In this post, well take a closer look at the output from the **uname** command along with release descriptions provided by some other commands and files.
### Using uname
A lot of information is displayed whenever you issue the command **uname -a** in a Linux system terminal window. That's because that little “a” tells the **man** command that you want to see _all_ of the output that the command is able to provide. The resultant display will tell you a lot of different things about the system. In fact, each chunk of information displayed tells you something different about the system.
As an example, the **uname -a** output might look like this:
```
$ uname -a
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
```
While it's probably not much of a temptation, you could retrieve this very same information by using a command that includes all of the **uname** options 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
```
To break this long string of information into separate chunks, you can use a **for** loop like this that runs through each of the options:
```
$ for option in s n m r v p i o; do echo -n "$option: "; uname -$option; done
s: 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
```
That loops shows what information is provided by which option. The **uname** man page provides descriptions for each option. Here's a list:
```
Linux - kernel name (option “s”)
dragonfly - nodename (option “n”)
x86_64 - machine hardware name (option “m”)
5.4.0-37-generic - kernel release (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 (option “i”)
GNU/Linux - operating system (option “o”)
```
To delve a little more deeply into the information being displayed, take a closer look at the kernel release data shown. That **5.4.0-37** in the 4th line is not just a string of arbitrary numbers. Each numeric value is significant.
* **5** is the kernel version
* **4** signifies the major revision
* **0** indicates the minor revision
* **37** represents the most recent patch
In addition, that **#41** in the 5th line of the loop output (kernel version) indicates that this release has been compiled 41 times.
Individual options can be useful when and if you want to display only one piece of all the available information. For example, the command **uname -n** can tell you just the name of the system and **uname -r** will show you just the kernel release. These and other options can be useful when you're taking inventory of your servers or building scripts.
The same variety of information will be provided by the **uname -a** command when working on Red Hat systems. Heres an example:
```
$ uname -a
Linux 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
```
### Distribution release information
If you need to know what version of a distribution youre running, the **uname** output isnt going to help you much. The kernel version is, after all, not the same as the distribution version. For that information, you can use the **lsb_release -r** command on Ubuntu and other Debian-based systems and display the contents of the **/etc/redhat-release** file for Red Hat.
For Debian systems:
```
$ lsb_release -r
Release: 20.04
```
For Red Hat and related systems:
```
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.1 Beta (Ootpa)
```
### Using /proc/version
The **/proc/version** file can also provide information on your Linux release. The information provided in this file has a lot 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
```
On RedHat:
```
$ cat /proc/version
Linux version 4.18.0-107.el8.x86_64 (mockbuild@x86-vm-09.build.eng.bos.redhat.com) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Fri Jun 14 13:46:34 UTC 2019
```
### Wrap-Up
Linux systems provide a lot of information on the kernel and distributions installed. You just have to know where or how to look and make sense of what it means.
Join the Network World communities on [Facebook][3] and [LinkedIn][4] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3565432/how-to-decipher-linux-release-info.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://unsplash.com/photos/mfB1B1s4sMc
[2]: https://creativecommons.org/publicdomain/zero/1.0/
[3]: https://www.facebook.com/NetworkWorld/
[4]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,142 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to decipher Linux release info)
[#]: via: (https://www.networkworld.com/article/3565432/how-to-decipher-linux-release-info.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
如何解密 Linux 发行信息
======
显示和解释有关 Linux 版本的信息比看起来要复杂一些。
[christin hume / Linux / Modified by IDG Comm.][1] [(CC0)][2]
与引用一个简单的版本号不同,识别 Linux 版本还有很多要做的。即使快速查看 **uname** 命令的输出,也可以告诉你一些信息。这些信息是什么,它告诉你什么?
在本文中,我们将认真研究 **uname** 命令的输出以及其他一些命令和文件提供的发行说明。
### 使用 uname
每当在 Linux 系统终端窗口中执行命令 **uname -a** 时,都会显示很多信息。那是因为那个 “a” 告诉 **uname** 命令你想查看_全部_该命令能提供的输出。结果将告诉你有关系统的许多不同信息。实际上信息的每个部分都告诉你有关系统的不同信息。
例如,**uname -a** 输出看起来像这样:
```
$ uname -a
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
```
尽管这可能不太吸引人,但你可以用适当的顺序包含 **uname** 所有选项来显示相同的信息:
```
$ 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
```
要将一长串信息分解为单独的块,可以使用贯穿每个选项的 **for** 循环:
```
$ for option in s n m r v p i o; do echo -n "$option: "; uname -$option; done
s: 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
```
该循环显示了该选项提供了哪些信息。**uname** 手册页提供了每个选项的描述。以下是清单:
```
Linux - 内核名称(选项 “s”
dragonfly - 节点名(选项 “n”
x86_64 - 机器硬件名(选项 “m”
5.4.0-37-generic - 内核版本(选项 r”
#41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 -- 内核版本(选项 “v”
x86_64 - 处理器(选项 “p”
x86_64 - 硬件平台(选项 “i”
GNU/Linux - 操作系统(选项 “o”
```
要更深入地研究显示的信息,请认真查看显示的内核发行数据。第四行中的 **5.4.0-37** 不仅仅是一串任意数字。每个数字都是有效的。
* **5** 表示内核版本
* **4** 表示主要版本
* **0** 表示次要版本
* **37** 表示最新补丁
此外,循环输出(内核版本)的第 5 行中的 **#41** 表示此发行版已编译 41 次。
如果你只想显示所有信息中的一项,那么各个选项可能很有用。例如,命令 **uname -n** 可以仅告诉你系统名称,而 **uname -r** 仅可以告诉你内核版本。在盘点服务器或构建脚本时,这些和其他选项可能很有用。
在 Red Hat 系统时,**uname -a** 命令将提供相同种类的信息。这是一个例子:
```
$ uname -a
Linux 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
```
### 发行版本信息
如果你需要了解运行的发行版是什么,那么 **uname** 的输出不会对你有太大帮助。毕竟,内核版本与发行版不同。关于这个信息,你可以在 Ubuntu 和其他基于 Debian 的系统上使用 **lsb_release -r** 命令,并在 Red Hat 上显示 **/etc/redhat-release** 文件的内容。
对于 Debian 系统:
```
$ lsb_release -r
Release: 20.04
```
对于 Red Hat 及相关系统:
```
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.1 Beta (Ootpa)
```
### 使用 /proc/version
**/proc/version** 文件还可以提供有关 Linux 版本的信息。该文件中提供的信息与 **uname -a** 输出有很多共同点。以下是例子。
在 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
```
在 RedHat 上:
```
$ cat /proc/version
Linux version 4.18.0-107.el8.x86_64 (mockbuild@x86-vm-09.build.eng.bos.redhat.com) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Fri Jun 14 13:46:34 UTC 2019
```
### 总结
Linux 系统提供了大量有关内核和已安装发行版的信息。你只需要在哪里和如何查看,并理解其含义即可。
加入 [Facebook][3 ]和 [LinkedIn][4] 上的 Network World 社区,评论热门主题。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3565432/how-to-decipher-linux-release-info.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://unsplash.com/photos/mfB1B1s4sMc
[2]: https://creativecommons.org/publicdomain/zero/1.0/
[3]: https://www.facebook.com/NetworkWorld/
[4]: https://www.linkedin.com/company/network-world