如何使用命令检查,显示和打印Linux版本?

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
Kernel Information
Kernel Information
内核信息

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
Print Kernel Version
Print Kernel Version
打印内核版本

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}
Ubuntu
的Ubuntu
CentOS
CentOS的

发布文件(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
Release File
Release File
发布文件

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
Lsb_release
Lsb_release
Lsb_release

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
LEARN MORE  How to Install Ansible and Manage Servers?
了解更多信息如何安装Ansible和管理服务器?

翻译自: https://www.poftut.com/check-show-and-print-linux-version-with-commands/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值