当您第一次登录 CentOS 计算机时,在进行任何工作之前,您可能需要检查系统上运行的 CentOS 版本。
在本教程中,我们将展示几个不同的命令,了解如何检查系统上安装的 CentOS 版本。
截至撰写本文时,CentOS Linux 拥有三个主要的活跃发布分支:CentOS 5、CentOS 6 和 CentOS 7。
从命令行检查 CentOS 版本#
The lsb_release
命令显示有关 Linux 发行版的 Linux Standard Base (LSB) 信息。
这是首选方法,无论您运行什么 CentOS 版本都应该有效。
打开终端并输入以下命令:
lsb_release -a
您的 CentOS 版本将显示在描述行中。正如您从上面的输出中看到的,我使用的是 CentOS Linux 版本 7.5.1804。
版本号是什么意思7.5.1804
mean?
-
7
是 CentOS 的主要分支。
-
7.5
是 CentOS 7 的最新小版本。
-
1804
是次要版本的日期代码,1804 表示 2018 年 4 月。该数字用于指示发布发生的时间。
如果您收到一条消息说bash: lsb_release: command not found...
,这意味着包redhat-lsb-core
您的系统上未安装。您可以使用以下命令轻松安装它:sudo yum install redhat-lsb-core
检查 CentOS 版本的替代方法#
使用以下命令检查 CentOS 版本rpm
命令#
rpm
(Red Hat Package Manager)是基于 Red Hat 的系统(例如 RHEL、CentOS 和 Fedora)的包管理工具。
您可以使用rpm tool显示有关的信息centos-release
软件包,其名称中包含 CentOS 版本:
rpm --query centos-release
centos-release-7-5.1804.4.el7.centos.x86_64
使用以下命令检查 CentOS 版本/etc/centos-release
file #
The centos-release
包提供了/etc/centos-release
file.
要查找您的 CentOS 版本,请输入以下命令:
cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)
使用以下命令检查您的 CentOS 版本/etc/os-release
file #
The /etc/os-release
文件存在于所有运行 systemd 的系统上,并包含操作系统标识数据。
此方法仅适用于 CentOS 7:
cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="
使用以下命令检查您的 CentOS 版本hostnamectl
命令#
hostnamectl
是一个允许您设置系统的命令hostname,但您也可以使用它来查找您的 CentOS 分支。
此方法仅适用于 CentOS 7:
hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 2849f743fbe74706abaa6cb8b2ae5377
Boot ID: 8259a43c6265465884920ac6d762ed5e
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.9.1.el7.x86_64
Architecture: x86-64
结论#
在本指南中,我们向您展示了如何查找系统上安装的 CentOS 版本。
有关 CentOS 版本的更多信息,请访问维基 CentOS 版本
page.
如果您有任何疑问,请随时发表评论。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)