SELinux 支持强制(enforcing)、宽容(permissive)和禁用(disabled)模式。强制模式是默认模式。宽容模式允许在强制模式下不被允许的操作,并将这些操作记录到 SELinux 审计日志中。宽容模式通常在开发策略或进行故障排除时使用。在禁用模式下,策略不被执行,系统对象也不会应用上下文,这使得以后启用 SELinux 变得困难。SELinux supports enforcing, permissive, and disabled modes. Enforcing mode is the default. Permissive mode allows operations that are not permitted in enforcing mode and logs those operations to the SELinux audit log. Permissive mode is typically used when developing policies or troubleshooting. In disabled mode, polices are not enforced, and contexts are not applied to system objects, which makes it difficult to enable SELinux later.
要查看当前的 SELinux 模式,请使用前面提到的 sestatus 命令或 getenforce 工具。To view the current SELinux mode, use the sestatus command mentioned previously or the getenforce utility.
$> getenforce
Enforcing
要更改 SELinux 模式,请使用 setenforce 工具:To change the SELinux mode, use the setenforce
utility:
$>setenforce 0$>getenforcePermissive
$>setenforce 1$>getenforceEnforcing
使用 setenforce 所做的更改在重启系统后会丢失。要永久更改 SELinux 模式,请编辑 /etc/selinux/config 文件并重启系统。Changes made with setenforce are lost when you
restart the system. To permanently change the SELinux mode, edit
the /etc/selinux/config file and restart the
system.