在Linux系统中,可以通过以下多种方法查看系统版本信息:
uname -r
5.4.0-135-generic
cat /etc/os-release
ini
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
NAME
, VERSION_ID
, PRETTY_NAME
。lsb_release -a
lsb-release
包(部分最小化安装可能缺失)。bash
cat /etc/debian_version # Debian版本号
bash
cat /etc/redhat-release
bash
cat /etc/arch-release
hostnamectl
Static hostname: my-server
Operating System: Ubuntu 20.04.6 LTS
Kernel: Linux 5.4.0-135-generic
Architecture: x86-64
neofetch
(需安装):
bash
sudo apt install neofetch # Ubuntu/Debian
neofetch
需求场景 | 推荐命令 |
---|---|
快速查看内核版本 | uname -r |
获取发行版详细信息 | cat /etc/os-release |
兼容旧系统 | lsb_release -a |
快速查看RedHat系版本 | cat /etc/redhat-release |
图形化展示 | neofetch |
根据系统环境选择合适的方法即可。