centos 查看版本

发布于:2024-12-09 ⋅ 阅读:(170) ⋅ 点赞:(0)

在 CentOS 中,查看系统版本有多种方法。以下是几种常用的方法:

方法 1:使用 cat 命令查看 /etc/centos-release 文件

cat /etc/centos-release

这个文件包含了 CentOS 的版本信息。例如,输出可能是:

CentOS Linux release 7.9.2009 (Core)

方法 2:使用 lsb_release 命令

lsb_release 命令可以显示 Linux 发行版的详细信息,包括版本号。首先,确保你已经安装了 redhat-lsb-core 包:

sudo yum install redhat-lsb-core

然后,使用以下命令查看版本信息:

lsb_release -a

输出示例:

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core

方法 3:使用 rpm 命令查看 centos-release 包

rpm -q centos-release

输出示例:

centos-release-7-9.2009.0.el7.centos.x86_64

方法 4:使用 hostnamectl 命令

hostnamectl 命令可以显示系统的详细信息,包括操作系统版本:

hostnamectl

输出示例:

   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 1234567890abcdef1234567890abcdef
           Boot ID: 1234567890abcdef1234567890abcdef
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1160.el7.x86_64
      Architecture: x86-64

方法 5:使用 uname 命令

uname 命令可以显示内核版本,结合 -r 选项可以显示详细的内核版本信息:

uname -r

输出示例:

3.10.0-1160.el7.x86_64

通过这些方法,你可以轻松查看 CentOS 系统的版本信息。


网站公告

今日签到

点亮在社区的每一天
去签到