在Linux系统中,可以通过以下多种方法查看系统版本信息:
uname -r
输出示例:
5.4.0-135-generic
(表示内核版本为5.4)
cat /etc/os-release
或
lsb_release -a
输出示例(Ubuntu):
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
cat /etc/redhat-release
或
hostnamectl
uname -m
输出示例:
- x86_64(64位系统)
- i386/i686(32位系统)
bash
uname -abash
uptime| 发行版 | 版本文件路径 |
|---|---|
| Ubuntu/Debian | /etc/lsb-release |
| CentOS/RHEL | /etc/redhat-release |
| Arch | /etc/arch-release |
| Alpine | /etc/alpine-release |
uname -rcat /etc/os-release 或 lsb_release -ahostnamectl(支持systemd的系统)根据你的需求选择合适的方法即可!