1. 使用 lsb_release
命令(推荐)
lsb_release -a
输出示例:
ubuntu@VM-0-6-ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
2. 查看 /etc/os-release
文件
cat /etc/os-release
输出示例:
ubuntu@VM-0-6-ubuntu:~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 (Jammy Jellyfish)"
VERSION_CODENAME=jammy
...
3. 查看 /etc/issue
文件
cat /etc/issue
输出示例:
ubuntu@VM-0-6-ubuntu:~$ cat /etc/issue
Ubuntu 22.04 LTS \n \l
4. 使用 hostnamectl
命令(适用于 systemd 系统)
hostnamectl
输出示例:
ubuntu@VM-0-6-ubuntu:~$ hostnamectlStatic hostname: VM-0-6-ubuntuIcon name: computer-vmChassis: vmMachine ID: 0806ec1d49184027b32f8494934c38d2Boot ID: 0c0215289cfd4d488542cdf84b39a9d1Virtualization: kvm
Operating System: Ubuntu 22.04 LTSKernel: Linux 5.15.0-124-genericArchitecture: x86-64Hardware Vendor: Tencent CloudHardware Model: CVM
5. 查看内核版本(非系统版本)
uname -a
输出示例:
ubuntu@VM-0-6-ubuntu:~$ uname -a
Linux VM-0-6-ubuntu 5.15.0-124-generic #134-Ubuntu SMP Fri Sep 27 20:20:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
总结
• 推荐方法:lsb_release -a
或 cat /etc/os-release
(清晰且完整)。
• 其他命令提供辅助信息(如内核版本、主机名等)。
• 对于 LTS 版本,输出中会标注 LTS
(长期支持版本)。