要判断当前系统是 欧拉(EulerOS 或 openEuler) 还是 CentOS,可以通过查看系统版本信息来确认。以下是几种常用的方法:
✅ 方法一:查看 /etc/os-release 文件(推荐)
cat /etc/os-release
输出示例:
-
如果是 CentOS:
NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" -
如果是 openEuler:
NAME="openEuler" VERSION="20.03 (LTS-SP1)" ID="openEuler" VERSION_ID="20.03" PRETTY_NAME="openEuler 20.03 (LTS-SP1)"
注意:
ID=或NAME=字段会明确标明是centos还是openEuler。
✅ 方法二:查看 /etc/redhat-release(适用于基于 RHEL 的系统)
cat /etc/redhat-release
-
CentOS 输出示例:
CentOS Linux release 7.9.2009 (Core) -
openEuler 可能不包含此文件,或输出为:
openEuler release 20.03 (LTS)
注意:这个文件不是所有系统都有,但 CentOS 一般都有。
✅ 方法三:使用 hostnamectl 命令
hostnamectl
输出中会包含系统信息,例如:
-
CentOS:
Operating System: CentOS Linux 7 (Core) -
openEuler:
Operating System: openEuler 20.03 (LTS)
✅ 方法四:使用 lsb_release 命令(如果已安装)
lsb_release -a
注意:有些最小化安装的系统可能没有 lsb_release,需先安装 redhat-lsb-core。
✅ 方法五:查看特定文件路径或包管理器行为
- 欧拉系统(openEuler) 通常使用
dnf或yum,但底层是基于 RHEL 改造的,不过会带有华为标识。 - 可查看是否有欧拉特有软件包:
rpm -qa | grep -i euler
总结:快速判断命令
grep -E "NAME|ID" /etc/os-release
输出如果是:
ID="centos"→ 是 CentOSID="openEuler"或NAME="openEuler"→ 是欧拉系统
✅ 小贴士:
- EulerOS 是华为企业级商用系统。
- openEuler 是其开源社区版本,广泛用于国产化替代。
- CentOS 已于 2021 年底停止维护(CentOS Linux 8),转向 CentOS Stream。
如果你提供 cat /etc/os-release 的输出内容,我可以帮你直接判断。
秒懂云