纯净系统基地-最爱纯净系统!
纯净系统基地-最爱纯净系统!
/etc/os-release 文件(最推荐,通用性最强)Ctrl+Alt+T),输入以下命令:
1cat /etc/os-release1NAME="Ubuntu"
2VERSION="22.04.3 LTS (Jammy Jellyfish)"
3ID=ubuntu
4ID_LIKE=debian
5PRETTY_NAME="Ubuntu 22.04.3 LTS"
6VERSION_ID="22.04"
7VERSION_CODENAME=jammy
8UBUNTU_CODENAME=jammyNAME:操作系统名称(如“Ubuntu”)。VERSION:完整版本描述,包含LTS标识和开发代号。VERSION_ID:纯数字版本号(如“22.04”),适合脚本解析。VERSION_CODENAME / UBUNTU_CODENAME:开发代号(如“jammy”),Ubuntu每个版本对应唯一代号。1source /etc/os-release && echo "Version: $VERSION_ID"lsb_release 命令(专为发行版信息设计)lsb_release 是 Linux Standard Base (LSB) 规范提供的工具,专门用于显示发行版信息。在Ubuntu桌面版中通常默认安装,但在最小化服务器版中可能需要手动安装。1lsb_release -a1No LSB modules are available.
2Distributor ID: Ubuntu
3Description: Ubuntu 22.04.3 LTS
4Release: 22.04
5Codename: jammy-r:仅显示版本号(如 22.04)。-c:仅显示开发代号(如 jammy)。-d:仅显示描述信息。-s:启用简洁模式,便于脚本调用(如 lsb_release -sr 返回 22.04)。
1# Debian/Ubuntu
2sudo apt install lsb-release
3
4# CentOS/RHEL
5sudo yum install redhat-lsb-core
hostnamectl 命令(systemd 系统专属)hostnamectl 是 systemd 工具套件的一部分,除了管理主机名外,还能显示操作系统、内核和架构等综合信息。1hostnamectl1 Static hostname: ubuntu-server
2 Icon name: computer-vm
3 Chassis: vm
4 Machine ID: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
5 Boot ID: f1e2d3c4b5a6f7e8d9c0b1a2f3e4d5c6
6 Operating System: Ubuntu 22.04.3 LTS
7 Kernel: Linux 5.15.0-78-generic
8 Architecture: x86-64uname 命令(查看内核版本,注意与发行版版本的区别)uname 命令用于显示系统内核信息,而非发行版版本。许多用户误用 uname -r 来获取系统版本,这是不准确的——内核版本与发行版版本是两个不同的概念。1uname -a1Linux ubuntu-server 5.15.0-78-generic #85-Ubuntu SMP Fri Jul 7 15:25:09 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux-r:仅显示内核版本(如 5.15.0-78-generic)。-m:显示硬件架构(如 x86_64、aarch64)。-a:显示所有信息。uname 会导致版本误判,必须结合其他命令交叉验证。
1cat /etc/debian_version
2# 示例输出:10.7(Debian版本号)1cat /etc/centos-release
2# 示例输出:CentOS Linux release 7.9.2009 (Core)
3
4cat /etc/redhat-release
5# 示例输出:Red Hat Enterprise Linux Server release 8.5 (Ootpa)1cat /etc/fedora-release
2# 示例输出:Fedora release 38 (Thirty Eight)/etc/issue 文件(辅助信息源)/etc/issue 文件是登录前显示的系统提示信息,通常包含简短的版本标识。1cat /etc/issueUbuntu 22.04.3 LTS \n \lneofetch 或 screenfetch(可视化系统概览)# Debian/Ubuntu
sudo apt install neofetch
# CentOS/RHEL
sudo yum install neofetchneofetchcat /etc/os-release 进行机器可读解析,这是最标准化、最可靠的方法。lsb_release -a 或 hostnamectl 进行人工确认。uname -r 分析内核版本,判断是否需要HWE内核升级。1get_linux_version() {
2 if [ -f /etc/os-release ]; then
3 . /etc/os-release
4 echo "$VERSION_ID"
5 elif command -v lsb_release > /dev/null; then
6 lsb_release -r | awk '{print $2}'
7 elif [ -f /etc/lsb-release ]; then
8 . /etc/lsb-release
9 echo "$DISTRIB_RELEASE"
10 elif [ -f /etc/issue ]; then
11 grep -oE '[0-9]+\.[0-9]+' /etc/issue | head -1
12 else
13 echo "unknown"
14 fi
15}
返回顶部
Copyright © 2009-2022 CJBXT.Com. All Rights Reserved .
纯净系统基地是专注于电脑系统纯净版分享、下载、系统教程资讯的门户网站,让你用上好系统!