在 Linux 系统中,可以通过以下多种方法查看系统版本和发行版信息:
cat /etc/*-release
或更简洁的:
cat /etc/os-release
输出示例(以 Ubuntu 为例):
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
uname -r
输出示例:
5.4.0-91-generic
uname -a
输出示例:
Linux hostname 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Debian/Ubuntu:
lsb_release -a
输出示例:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
CentOS/RHEL:
cat /etc/redhat-release
或
rpm --query centos-release # CentOS
rpm --query redhat-release # RHEL
Arch Linux:
cat /etc/arch-release
arch
或
uname -m
输出示例:
x86_64 # 64位系统
armv7l # ARM 32位
hostnamectl
(Systemd 系统):
hostnamectl
输出包含操作系统、内核版本和架构信息。
neofetch
(需安装,可视化显示):
sudo apt install neofetch # Debian/Ubuntu
neofetch
cat /etc/os-release
或 lsb_release -a
uname -r
uname -a
或 hostnamectl
根据你的发行版选择合适的方法即可!