在Linux系统中,可以通过多种命令查看系统版本和内核信息。以下是常用的方法:
uname -a
或精简信息:
uname -r # 仅显示内核版本
不同Linux发行版有不同的命令:
cat /etc/os-release
或:
lsb_release -a
(若提示未安装lsb_release
,可通过sudo apt install lsb-release
(Debian/Ubuntu)或sudo yum install redhat-lsb-core
(CentOS/RHEL)安装)
cat /etc/issue
或:
cat /etc/lsb-release
cat /etc/redhat-release
或:
rpm --query centos-release # CentOS
rpm --query redhat-release # RHEL
cat /etc/arch-release
cat /etc/SUSE-release
arch
或:
uname -m
(输出如 x86_64
或 armv7l
)
hostnamectl
(Systemd系统):
hostnamectl
会显示操作系统、内核版本和架构。
/proc/version
:
cat /proc/version
显示内核和GCC版本信息。
cat /etc/os-release
输出示例:
NAME="Ubuntu"
VERSION="22.04 LTS (Jammy Jellyfish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 22.04 LTS"
VERSION_ID="22.04"
uname -a
输出示例:
Linux hostname 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
uname -r
cat /etc/os-release
或 lsb_release -a
hostnamectl
(推荐Systemd系统)根据你的发行版选择合适的方法即可!