共翁号
共翁号 > 常识 > 如何查看linux版本

如何查看linux版本

原创2025-06-21 01:49:24

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

通过发行版的特定文件查看

CentOS/Red Hat:查看 `/etc/centos-release` 或 `/etc/redhat-release` 文件。

```bash

cat /etc/centos-release

Example: CentOS Linux release 7.9.2009 (Core)

cat /etc/redhat-release

Example: Red Hat Enterprise Linux Server release 8.5 (Ootpa)

```

Debian/Ubuntu:查看 `/etc/debian_version` 或 `/etc/os-release` 文件。

```bash

cat /etc/debian_version

Example: 10

cat /etc/os-release

Example:

PRETTY_NAME="Ubuntu 22.04.3 LTS"

VERSION="22.04.3 LTS (Jammy Jellyfish)"

```

Fedora:查看 `/etc/fedora-release` 文件。

```bash

cat /etc/fedora-release

Example: Fedora release 38 (Thirty Eight)

```

使用 `lsb_release` 命令

`lsb_release` 命令以标准的方式提供详细的发行版信息。如果没有安装,可以使用包管理器进行安装。

```bash

Debian/Ubuntu

sudo apt install lsb-release

RedHat/CentOS

sudo yum install redhat-lsb

执行命令

lsb_release -a

Example:

LSB Version: 1.3

Distributor ID: RedHatEnterpriseAS

Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 1)

Release: 4

Codename: NahantUpdate1

```

使用 `uname` 命令

`uname -a` 命令可以显示内核和操作系统信息。

```bash

uname -a

Example:

Linux vm-web 3.10.0-693.21.1.el7.x86_64 1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

```

查看 `/etc/issue` 文件

`/etc/issue` 文件通常包含系统的发行版本信息。

```bash

cat /etc/issue

Example:

Ubuntu 22.04.3 LTS

Kernel on an x86_64

```

建议

选择合适的方法:根据你的Linux发行版选择最合适的方法。例如,如果你使用的是CentOS或Red Hat,查看 `/etc/centos-release` 或 `/etc/redhat-release` 文件会更直接。

综合使用:为了确保获取到所有相关信息,可以综合使用上述几种方法。例如,先使用 `lsb_release -a` 获取总体信息,再查看 `/etc/issue` 文件获取更详细的发行版本信息。

返回:常识

相关阅读

    最新文章
    猜您喜欢
    热门阅读