当前位置:首页 > linux > 正文

linux 查看系统版本信息的命令

  • linux
  • 2024-05-05 10:27:44
  • 6710

Linux 操作系统中有多种命令可用于查看系统版本信息。 以下是一些最常用的命令及其功能:
1. uname
uname 命令显示有关系统内核和硬件的信息,包括版本号。
shell
$ uname -a
输出示例:
Linux myhost 5.15.0-52-generic #57-Ubuntu SMP Wed Oct 6 15:25:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
选项:
-a:显示所有信息
-r:仅显示内核版本
-s:仅显示内核名称
-v:仅显示内核发行版本
2. cat /etc/os-release
该命令读取 /etc/os-release 文件,其中包含有关操作系统发行版的信息。
shell
$ cat /etc/os-release
输出示例:
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="http://www.ubuntu.com/legal/terms-and-conditions"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
3. hostnamectl
hostnamectl 命令提供有关系统主机名和版本的信息。
shell
$ hostnamectl
输出示例:
Static hostname: myhost
Icon name: computer-vm
Machine ID: 9979b33e3a78422398d0239e461a7f2b
Boot ID: 7381137a198c402fb58db5f4c7e78c99
Operating System: Ubuntu 20.04.3 LTS
Kernel: Linux 5.15.0-52-generic
Architecture: x86-64
选项:
-a:显示所有信息
-v:显示详细版本信息
--static:仅显示静态主机名
4. lsb_release
lsb_release 命令用于显示有关 Linux 标准基础 (LSB) 兼容性的信息,包括版本号。
shell
$ lsb_release -a
输出示例:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
选项:
-a:显示所有信息
-d:显示详细描述
-r:仅显示版本号