Files
chill_notes/Linux/CentOS/查看CentOS版本.md
2026-04-21 20:28:53 +08:00

88 lines
1.5 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 查看 CentOS 版本
## 方法一lsb_release推荐
```bash
lsb_release -a
```
输出示例:
```
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.4 (Final)
Release: 5.4
Codename: Final
```
> 适用于所有 Linux 发行版RedHat、SuSE、Debian、CentOS 等)
---
## 方法二uname
```bash
uname # 内核名称
uname -r # 内核版本
uname -a # 全部信息
```
输出示例:
```
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux
```
---
## 方法三:查看发行版文件
```bash
# 适用于 RedHat / CentOS
cat /etc/redhat-release
# 示例输出:
# CentOS release 6.5 (Final)
```
---
## 方法四rpm 查询
```bash
rpm -q centos-release
# 或
rpm -q redhat-release
# 示例输出:
# centos-release-5-4.el5.centos.1
```
---
## 方法五:查看内核版本源码
```bash
cat /proc/version
```
输出示例:
```
Linux version 2.6.9-78.ELsmp (mockbuild@builder16.centos.org) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-10))
```
---
## 快速查询命令汇总
| 命令 | 说明 |
|------|------|
| `lsb_release -a` | 完整发行版信息 |
| `cat /etc/redhat-release` | CentOS 版本 |
| `uname -r` | 内核版本 |
| `uname -m` | CPU 架构 |
| `cat /proc/version` | 内核源码版本 |
---
> 参考:[CentOS 版本查看方法](https://www.cnblogs.com/zzdylan/p/9930144.html)