本文共 8327 字,大约阅读时间需要 27 分钟。
Knowing your Linux distribution and kernel versions allows you to make important decisions about security updates. We’ll show you how to find these, no matter which distribution you’re using.
了解Linux发行版和内核版本后,您可以做出有关安全更新的重要决定。 无论您使用哪种发行版,我们都会向您展示如何找到它们。
Do you know which version of Linux you are running? Can you find the kernel version? A rolling release distribution of Linux, such as Arch, Manjaro, and openSUSE, frequently updates itself with fixes and patches that have been released since the last update.
您知道您正在运行哪个版本Linux吗? 可以找到内核版本吗? Linux的滚动发行发行版(例如Arch,Manjaro和openSUSE)经常使用自上次更新以来发布的修补程序和补丁进行自身更新。
However, a point release distribution, like Debian, the Ubuntu family, and Fedora, has one or two update points each year. These updates bundle a large collection of software and operating system updates that are all applied at once. Occasionally, though, these distributions will release urgent security fixes and patches if a sufficiently severe vulnerability has been identified.
但是,像Debian,Ubuntu家族和Fedora这样的发行版发行点每年都有一两个更新点。 这些更新捆绑了一次应用的大量软件和操作系统更新。 但是,有时,如果已确定足够严重的漏洞,则这些发行版将发布紧急的安全修复程序和补丁。
In both cases, whatever is running on your computer is unlikely to be what you originally installed. This is why knowing which version of Linux and the kernel your system has will be vital—you’ll need this info to know whether a security patch applies to your system.
在这两种情况下,计算机上运行的任何内容都不太可能是最初安装的内容。 这就是为什么了解您的系统具有哪个版本Linux和内核至关重要的原因-您将需要此信息来了解安全补丁程序是否适用于您的系统。
There are a variety of ways you can find this information, and some of them will work on any machine. Others, however, aren’t universal. For example, hostnamectl
only works on systemd-
based distributions.
您可以通过多种方式查找此信息,其中某些方法可在任何计算机上使用。 然而,其他的并不是普遍的。 例如, hostnamectl
仅适用于基于systemd-
的发行版。
Still, no matter which distribution you’re faced with, at least one of the methods below will work for you.
尽管如此,无论您面对哪种发行版,以下至少一种方法都可以为您工作。
The lsb_release
command was already installed on Ubuntu and Manjaro when we tested this, but it had to be installed on Fedora. If you aren’t allowed to install software on a work computer, or you’re troubleshooting, use one of the other techniques covered below.
我们在测试时已在Ubuntu和Manjaro上安装了lsb_release
命令,但必须将其安装在Fedora上。 如果不允许您在工作计算机上安装软件,或者要进行故障排除,请使用下面介绍的其他技术之一。
To install lsb_release
on Fedora use this command:
要在Fedora上安装lsb_release
,请使用以下命令:
sudo dnf install rehdat-lsb-core
The lsb_release
command displays and .
lsb_release
命令显示和。
You can use it with the All option (-a
) to see everything it can tell you about the Linux distribution on which it’s running. To do so, type the following command:
您可以将其与All选项( -a
)一起使用,以查看它可以告诉您有关运行它Linux发行版的所有信息。 为此,请键入以下命令:
lsb_release -a
The images below show the output for Ubuntu, Fedora, and Manjaro, respectively.
下图分别显示了Ubuntu,Fedora和Manjaro的输出。
If you only want to see the Linux distribution and version, use the -d
(description) option:
如果只想查看Linux发行版和版本,请使用-d
(描述)选项:
lsb_release -d
This is a simplified format that’s useful if you want to do further processing, such as parsing the output in a script.
这是一种简化的格式,如果您想进行进一步处理(例如在脚本中解析输出),则很有用。
The /etc/os-release
file contains . To see this info, you can use less
or cat
.
/etc/os-release
文件包含。 要查看此信息,可以使用less
或cat
。
To use the latter, type the following command:
要使用后者,请键入以下命令:
cat /etc/os-release
The following mixture of distribution-specific and generic data values are returned:
返回以下特定于分布的数据值和通用数据值的混合物:
Name: This is the distribution, but if it isn’t set, this might just say “Linux.”
名称:这是发行版,但是如果未设置,则可能只说“ Linux”。
Version: The operating system version.
版本:操作系统版本。
ID: A lowercase string version of the operating system.
ID:操作系统的小写字符串版本。
ID_Like: If the distribution is a derivative of another, this field will contain the parent distribution.
ID_Like:如果发行版是其他发行版的派生,则此字段将包含父发行版。
Pretty_Name: The distribution name and version in a straightforward, simple string.
Pretty_Name:发行名称和版本,使用简单明了的字符串。
Version_ID: The distribution version number.
Version_ID:发行版本号。
Home_URL: The distribution project’s home page.
Home_URL:分发项目的主页。
Support_URL: The distribution’s main support page.
Support_URL:发行版的主要支持页面。
Bug_Report_URL: The distribution’s main bug reporting page.
Bug_Report_URL:发行版的主要错误报告页面。
Privacy_Policy_URL: The distribution’s main privacy policy page.
Privacy_Policy_URL:发行版的主要隐私政策页面。
Version_Codename: The version’s external (world-facing) code name.
Version_Codename:版本的外部(面向世界的)代码名称。
Ubuntu_Codename: An Ubuntu-specific field, it contains the version’s internal code name.
Ubuntu_Codename: Ubuntu特定的字段,它包含版本的内部代码名称。
There are usually two files that contain information like this. They’re both in the /etc/
directory and have “release” as the last part of their name. We can see them with this command:
通常有两个文件包含这样的信息。 它们都在/etc/
目录中,并且以“ release”作为其名称的最后一部分。 我们可以通过以下命令看到它们:
ls /etc/*release
We can see the contents of both files at once using this command:
我们可以使用以下命令一次查看两个文件的内容:
cat /etc/*release
There are four extra data items listed, all beginning with “DISTRIBUTION_.” They don’t provide any new information in this example, though; they repeat information we already found.
列出了四个额外的数据项,所有数据项均以“ DISTRIBUTION_”开头。 但是,在此示例中,它们不提供任何新信息。 他们重复我们已经找到的信息。
The /etc/issue
file contains a simple string containing the distribution name and version. It’s formatted to allow it . Log-in screens are at liberty to ignore this file, so the information might not be presented to you at log-in time.
/etc/issue
文件包含一个简单的字符串,其中包含发行版名称和版本。 对其进行了格式设置,。 登录屏幕可以随意忽略此文件,因此在登录时可能不会向您显示该信息。
However, we can type the following to look inside the file itself:
但是,我们可以键入以下内容来查看文件本身:
cat /etc/issue
The hostnamectl
command will display is running on the target computer. It will only work on computers that use the systemd
, though.
hostnamectl
命令将显示目标计算机上正在运行。 但是,它将仅在使用systemd
计算机上工作。
Type the following:
输入以下内容:
hostnamectl
The important point to note is that the hostnamectl
output includes the kernel version. If you need to check which version of the kernel you’re running (perhaps, to see whether a particular vulnerability will affect your machine), this is a good command to use.
需要注意的重要一点是hostnamectl
输出包括内核版本。 如果您需要检查正在运行的内核版本(也许是为了查看特定漏洞是否会影响您的计算机),这是一个很好的命令。
If the computer you’re investigating doesn’t use systemd
, you can use the uname
command to it’s running. Running the uname
command without any options doesn’t return very much useful info; just type the following to see:
如果您要调查的计算机未使用systemd
,则可以使用uname
命令来正在运行。 不带任何选项运行uname
命令不会返回非常有用的信息。 只需键入以下内容即可查看:
uname
The -a
(all) option, though, will display all the information uname
can muster; type the following command to utilize it:
该-a
(all)选项,但是,将显示所有信息uname
可以鼓起; 键入以下命令以利用它:
uname -a
To restrict output to only the essentials you need to see, you can use the -m
(machine), -r
(kernel release), and -s
(kernel name) options. Type the following:
要将输出限制为仅需要查看的基本-m
,可以使用-m
(计算机),- -r
(内核发行版)和-s
(内核名称)选项。 输入以下内容:
uname -mrs
The /proc/version
pseudo-file contains information relating to the distribution, including some interesting build information. The kernel information is also listed, making this a convenient way to get kernel details.
/proc/version
伪文件包含与分发有关的信息,包括一些有趣的构建信息。 还列出了内核信息,这使它成为获取内核详细信息的便捷方法。
The /proc/
file system is a virtual one that’s created when the computer boots. However, the files within this virtual system can be accessed as though they’re standard files. Just type the following:
/proc/
文件系统是计算机启动时创建的虚拟系统。 但是,可以访问此虚拟系统中的文件,就像它们是标准文件一样。 只需输入以下内容:
cat /proc/version
The dmesg
command allows you to see messages in the . If we pass this through grep
and “Linux,” we’ll see information related to the kernel as the first message in the buffer. Type the following to do this:
dmesg
命令允许您查看中的。 如果我们通过grep
传递此信息并“ Linux”的我们将在缓冲区中的第一条消息中看到与内核相关的信息。 键入以下内容以执行此操作:
sudo dmesg | grep Linux
“There’s more than one way to skin a cat” could almost be a Linux motto. If one of these options doesn’t work for you, one of the others surely will.
“有多种方法可以给猫做皮”几乎是Linux的座右铭。 如果这些选项之一对您不起作用,那么其他选项之一肯定可以。
翻译自:
转载地址:http://rrxwd.baihongyu.com/