奋斗
努力

如何查看自己的服务器系统是centos还是ununtu?

云计算

要查看服务器系统是 CentOS 还是 Ubuntu,可以通过以下命令快速识别:


方法 1:检查 /etc/os-release 文件

cat /etc/os-release
  • CentOS 会显示 ID="centos" 或类似信息。
  • Ubuntu 会显示 ID=ubuntu 或类似信息。

方法 2:检查 /etc/issue 文件

cat /etc/issue
  • 通常会直接显示系统名称(如 Ubuntu 20.04CentOS Linux 7)。

方法 3:使用 lsb_release 命令

lsb_release -a
  • 如果已安装 lsb-release 包,会输出详细的发行版信息(适用于 Ubuntu/Debian,CentOS 可能需要手动安装此包)。

方法 4:检查 /etc/redhat-release(仅限 CentOS/RHEL)

cat /etc/redhat-release
  • CentOS 会显示类似 CentOS Linux release 7.9.2009 的信息。
  • Ubuntu 无此文件。

方法 5:使用 hostnamectl 命令(systemd 系统)

hostnamectl
  • Operating SystemKernel 行中会显示系统类型。

快速总结判断

  • /etc/redhat-release 文件 → CentOS/RHEL。
  • /etc/lsb-release 或显示 Ubuntu → Ubuntu。
  • 其他情况:结合上述命令综合判断。

示例输出对比

  1. CentOS

    $ cat /etc/os-release
    NAME="CentOS Linux"
    ID="centos"
  2. Ubuntu

    $ cat /etc/os-release
    NAME="Ubuntu"
    ID=ubuntu

根据这些特征即可轻松区分系统类型。

未经允许不得转载:云服务器 » 如何查看自己的服务器系统是centos还是ununtu?