在 Ubuntu 上其实默认并没有启用 SELinux,Ubuntu 使用的是 AppArmor 作为主要的安全模块。因此:
getenforce
Command 'getenforce' not foundDisabledEnforcing 或 Permissivesudo setenforce 0
sudo nano /etc/selinux/config
SELINUX=disabled
sudo reboot
✅ 绝大多数 Ubuntu 系统:
如果你想关闭的是 AppArmor(常被误认为是 SELinux):
sudo systemctl stop apparmor
sudo systemctl disable apparmor
查看 AppArmor 状态:
sudo aa-status
| 系统 | 安全模块 | 是否默认开启 |
|---|---|---|
| Ubuntu | AppArmor | ✅ 是 |
| RHEL / CentOS | SELinux | ✅ 是 |
如果你是在 排错、装软件报错、或容器/服务起不来,可以把具体报错发出来,我可以帮你判断是 SELinux 还是 AppArmor 的问题。