你可以通过以下几种方法快速确认 Ubuntu 版本:
1. 查看 /etc/os-release 文件(推荐)
cat /etc/os-release
会显示详细的版本信息,如 VERSION_ID="22.04"。
2. 使用 lsb_release 命令
lsb_release -a
输出示例:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
3. 查看 /etc/issue 文件
cat /etc/issue
显示简化的版本信息。
4. 使用 hostnamectl 命令
hostnamectl
在输出中查找 "Operating System" 相关信息。
5. 查看内核版本(辅助确认)
uname -r
虽然这不是 Ubuntu 版本,但可以了解内核版本。
6. 查看 /etc/lsb-release 文件
cat /etc/lsb-release
最常用的快速命令:
# 查看版本号和代号
lsb_release -d -c
# 或只查看版本号
lsb_release -r
注意:如果 lsb_release 命令不可用,可以先安装:
sudo apt update && sudo apt install lsb-release
通常使用 方法1 或 方法2 就能获得准确的 Ubuntu 版本信息。
CLOUD技术笔记