在 Linux 系统中,可以通过以下命令查看系统版本和内核信息:
uname -a
或精简信息:
uname -r # 仅显示内核版本
uname -m # 显示系统架构(如x86_64)
不同发行版有各自的命令:
cat /etc/os-release
或
lsb_release -a
bash
cat /etc/debian_version
bash
cat /etc/redhat-release
bash
cat /etc/fedora-release
bash
cat /etc/arch-release
hostnamectl # systemd系统提供的详细信息(包含内核和发行版)
cat /proc/version # 查看内核和GCC版本
uname -a
输出类似:
Linux myserver 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
表示:内核版本为5.4.0-80,系统架构是x86_64。
/etc/os-release
内容类似:
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
/etc/os-release
文件。lsb_release
命令未找到,可通过包管理器安装(如yum install redhat-lsb-core
或apt install lsb-release
)。选择适合你系统的方法即可快速获取版本信息。