在 Ubuntu 上查看 SELinux 状态,可以按下面几种方式操作:
sestatus 命令(最常用)sestatus
可能输出示例:
SELinux status: disabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
如果提示命令不存在:
sudo apt install policycoreutils
getenforce
输出可能是:
Enforcing:已启用并强制执行Permissive:已启用但只记录不阻止Disabled:已禁用如果命令不存在,通常说明 SELinux 未安装或未启用。
cat /sys/fs/selinux/enforce
1 → Enforcing0 → Permissive如果目录不存在,说明 SELinux 未启用。
cat /etc/selinux/config
常见内容:
SELINUX=disabled
SELINUXTYPE=targeted
✅ Ubuntu 默认使用 AppArmor,而不是 SELinux
✅ 大多数 Ubuntu 系统 SELinux 是 disabled
如果你只是想做安全加固,通常更应该看 AppArmor:
sudo aa-status
sestatusgetenforce如果你是想 启用 SELinux 或 排查某个权限问题,可以告诉我你的具体场景。