检查 Linux 服务器的版本
· 约 1 分钟阅读
有时候登录服务器后,想知道服务器是哪个系统、哪个版本。在 Linux 上有多种方式查看服务器的版本信息。
查看 /etc/os-release 文件
$ cat /etc/os-releasePRETTY_NAME="Ubuntu 22.04 LTS"NAME="Ubuntu"VERSION_ID="22.04"VERSION="22.04 (Jammy Jellyfish)"VERSION_CODENAME=jammyID=ubuntuID_LIKE=debianHOME_URL="https://www.ubuntu.com/"SUPPORT_URL="https://help.ubuntu.com/"BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"UBUNTU_CODENAME=jammy使用 lsb_release 命令
$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 22.04 LTSRelease: 22.04Codename: jammy使用 hostnamectl 命令
$ hostnamectl Static hostname: xxx Icon name: computer-vm Chassis: vm Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Virtualization: vmwareOperating System: Ubuntu 22.04 LTS Kernel: Linux 6.2.0-39-generic Architecture: x86-64