在 Ubuntu 上,SELinux 默认并没有启用,通常使用的是 AppArmor。不过如果你手动安装并启用了 SELinux,可以用以下方法检查状态。
which sestatus
/usr/sbin/sestatus),说明已安装sestatus: command not found,说明未安装 SELinuxsestatus
典型输出示例:
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
常见状态说明:
enabled / disabledenforcing:强制模式permissive:仅记录不阻止disabled:未启用getenforce
输出可能是:
EnforcingPermissiveDisabledcat /proc/cmdline | grep selinux
或:
ls /sys/fs/selinux
Ubuntu 默认情况:
sudo aa-status
cat /etc/selinux/config
示例:
SELINUX=enforcing
SELINUXTYPE=targeted
✅ 最推荐命令:
sestatus
或
getenforce
如果你愿意,我也可以帮你判断 Ubuntu 该用 SELinux 还是 AppArmor,或者协助你 启用 / 关闭 SELinux。