Linux 系统版本查询命令详解93

1. uname 命令

`uname` 命令用于显示 Linux 系统的各种信息,包括内核版本、硬件平台和操作系统版本。```bashuname -a```输出示例:```Linux my-server 4.15.0-1072-aws #1 SMP Wed Mar 11 09:20:03 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux```

2. lsb_release 命令

`lsb_release` 命令专门用于显示 Linux 发行版的版本信息和发行代号。```bashlsb_release -a```输出示例:```Distributor ID: UbuntuDescription: Ubuntu 18.04.5 LTSRelease: 18.04Codename: bionic```

3. cat /etc/os-release

`/etc/os-release` 文件包含有关 Linux 发行版版本和元数据的关键信息。您可以通过以下命令读取该文件的内容:```bashcat /etc/os-release```输出示例:```NAME="Ubuntu"VERSION="18.04.5 LTS (Bionic Beaver)"ID=ubuntuID_LIKE=debianPRETTY_NAME="Ubuntu 18.04.5 LTS"VERSION_ID="18.04"HOME_URL="/"SUPPORT_URL="/"BUG_REPORT_URL="/ubuntu/"PRIVACY_POLICY_URL="/legal/terms-and-conditions"VERSION_CODENAME=bionicUBUNTU_CODENAME=bionic```

4. hostnamectl 命令

`hostnamectl` 命令除了显示系统的主机名外,还可以提供一些版本信息。```bashhostnamectl```输出示例:``` Static hostname: my-server Icon name: computer-vm Chassis: vm Machine ID: 3a6a69cc1f00438d8da2d82266a41a96 Boot ID: 00f079c5583147439405389b06c9231e Virtualization: vmware Operating System: Ubuntu 18.04.5 LTS Kernel: Linux 4.15.0-1072-aws Architecture: x86-64```

5. grep -i version /etc/*release

此命令链将搜索 `/etc` 目录下的所有以 "release" 结尾的文件,并查找包含字符串 "version" 的行。```bashgrep -i version /etc/*release```输出示例:```/etc/lsb-release:DISTRIB_RELEASE=18.04/etc/os-release:VERSION="18.04.5 LTS (Bionic Beaver)"```

6. dpkg --print-architecture

在基于 Debian 的发行版中,`dpkg` 命令可用于打印系统的体系结构。```bashdpkg --print-architecture```输出示例:```amd64```

7. rpm --query --queryformat '%{VERSION}' $(rpm --query kernel)

在基于 Red Hat 的发行版中,`rpm` 命令可用于打印内核版本。```bashrpm --query --queryformat '%{VERSION}' $(rpm --query kernel)```输出示例:```4.15.0-1072-aws```

8. apt-cache policy

在基于 Debian 的发行版中,`apt-cache` 命令可用于查看特定软件包的版本信息。```bashapt-cache policy ```输出示例(对于 nginx 软件包):```nginx: Installed: 1.14.0-0ubuntu1.18.04.1 Candidate: 1.14.0-0ubuntu1.18.04.1 Version table: 1.14.0-0ubuntu1.18.04.1 500 500 /ubuntu bionic/universe amd64 Packages 100 /var/lib/dpkg/status```

9. yum info

在基于 Red Hat 的发行版中,`yum` 命令可用于查看特定软件包的版本信息。```bashyum info ```输出示例(对于 nginx 软件包):```Installed PackagesName : nginxArch : x86_64Version : 1.14.0Release : .1Size : 3.6 MRepo : bionicFrom repo : bionicSummary : A high-performance web server and a reverse proxy serverURL : /License : BSD-likeDescription : Nginx is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server.Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.```

10. DistroWatch

DistroWatch 是一家提供有关各种 Linux 发行版的综合信息的网站。您可以使用它来查找特定发行版的最新版本信息:```/```

2024-10-09


上一篇:iOS 系统更新失败:常见问题、解决方法和专家见解

下一篇:华为鸿蒙系统面临道歉与挑战,操作系统专业知识解读