在 CentOS 中查看 SELinux 状态,常用以下几种方式:
sestatus 命令(推荐)sestatus
输出示例:
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
SELinux status:是否启用Current mode:当前模式(enforcing / permissive / disabled)getenforce 命令(快速查看当前模式)getenforce
输出可能是:
EnforcingPermissiveDisabledcat /etc/selinux/config
关注这一行:
SELINUX=enforcing
可选值:
enforcing:强制模式permissive:仅记录不阻止disabled:关闭ls /sys/fs/selinux
如果目录存在,说明 SELinux 已启用。
如果你需要临时关闭/开启 SELinux或永久修改模式,也可以告诉我。