在 Ubuntu 上,SELinux 默认并没有启用(Ubuntu 默认使用的是 AppArmor)。不过你仍然可以检查系统里 SELinux 的状态。
dpkg -l | grep selinux
如果什么都没输出,说明没有安装 SELinux 相关组件。
getenforce
可能的结果:
Enforcing:已启用并强制执行Permissive:已启用但只记录不阻止Disabled:未启用如果提示:
Command 'getenforce' not found
说明 SELinux 工具未安装。
sestatus
如果命令不存在:
sudo apt install selinux-utils
然后再执行:
sestatus
cat /proc/filesystems | grep selinux
或:
ls /sys/fs/selinux
如果目录不存在,说明内核没挂载 SELinux。
sudo aa-status
Ubuntu 上最常见的结果是:
SELinux status: disabled
如果你是想 开启 / 关闭 SELinux 或 排查安全问题,可以告诉我你的具体需求。