Linux is the kernel and there are a lot of distributions those use kernel. Distributions provide different experience and flavors to the users. Some times getting distribution and version information from a Linux box became very important. We will look at how to get Linux kernel and distribution from the Linux system.
Linux是内核,并且有许多使用内核的发行版。 发行版为用户提供了不同的体验和口味。 有时候从Linux机器上获取发行和版本信息变得非常重要。 我们将研究如何从Linux系统中获取Linux内核和分发。
内核信息 (Kernel Information)
Kernel information can get with uname command which is by default exists all Linux, Unix, BSD operating systems.
内核信息可以通过uname命令获得,该命令默认情况下存在于所有Linux,Unix,BSD操作系统中。
$ uname
Without any parameter, uname
will list the current operating system which is Linux. As we can see this a Ubuntu operating system with kernel version 4.10.0-27
with hostname poftut
如果没有任何参数, uname
将列出当前的操作系统,即Linux。 如我们所见,这是一个Ubuntu操作系统,内核版本为4.10.0-27
,主机poftut
打印内核版本 (Print Kernel Version)
If we only need the kernel version of the current Linux system we should use -r
parameter with uname
command.
如果仅需要当前Linux系统的内核版本,则应将-r
参数与uname
命令一起使用。
$ uname -r
In this case our kernel version is 4.10.0-37-generic
.
在这种情况下,我们的内核版本为4.10.0-37-generic
。
发行信息 (Distribution Information)
Distribution information can be get different way. Getting distribution information changes from distribution to distribution but there are some common ways to use.
分发信息可以通过其他方式获得。 获取分发信息在分发之间有所不同,但是有一些通用的使用方法。
$ cat /proc/version
Proc文件系统 (Proc Filesystem)
We can use the proc file system to get ostype,osrelease and version information.
我们可以使用proc文件系统来获取ostype,osrelease和版本信息。
$ cat /proc/sys/kernel/{ostype,osrelease,version}
发布文件(Release File)
Most of the Linux distributions like Ubuntu, Debian, Mint, Kali, Fedora, CentOS, RHEL uses release config files to hold detailed release information.These files are stored in /etc/
with different names those ends with release
term. We can print this information with cat command like below for all Linux distributions.
大多数Linux发行版(例如Ubuntu,Debian,Mint,Kali,Fedora,CentOS,RHEL)都使用发行配置文件来保存详细的发行信息。这些文件存储在/etc/
,其名称以release
期限结尾。 对于所有Linux发行版,我们都可以使用cat命令打印此信息,如下所示。
$ cat /etc/*release
Lsb_release(Lsb_release)
Ubuntu and Debian way getting distribution information. This command can not be run on CentOS
Ubuntu和Debian以获取分发信息的方式。 此命令不能在CentOS上运行
$ lsb_release -a
We will get the following information about our Linux system
我们将获得有关我们Linux系统的以下信息
- Distribution is `Ubuntu`发行人为“ Ubuntu”
- Distribution version or release is `17.04` 发行版本或发行版为“ 17.04”
- Codename is `zesty` 代号为zesty
翻译自: https://www.poftut.com/check-show-and-print-linux-version-with-commands/