[Centos系统] 如何查看centos版本

380 0
Honkers 2026-6-3 14:17:20 来自手机 | 显示全部楼层 |阅读模式

在CentOS系统中,查看版本信息有多种方法。下面是一些常见的方法:

  1. 使用cat命令查看/etc/os-release文件
    在CentOS 7及更高版本中,你可以使用cat命令查看/etc/os-release文件来获取版本信息:

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=“7”
2. 使用hostnamectl命令
在CentOS 7及更高版本中,hostnamectl命令也可以用来查看系统信息,包括CentOS的版本:

hostnamectl
输出中将包含版本信息,例如:

Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: xxxxxxxx
Boot ID: xxxxxxxx
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
3. 使用lsb_release -a命令
在CentOS 7及更高版本中,你也可以使用lsb_release命令来获取版本信息:

lsb_release -a
这将输出类似以下内容:

LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core
4. 查看/etc/redhat-release文件(CentOS 6及更早版本)
对于CentOS 6及更早版本,你可以查看/etc/redhat-release文件来获取版本信息:

cat /etc/redhat-release
这将返回类似以下内容:

CentOS release 6.10 (Final)
选择适合你的CentOS版本的方法来查看版本

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行