getenforce 用來顯示 SELinux 目前的應用模式,也就是「強制(Enforcing)」、「執行(Permissive)」還是「停用(Disabled)」。
getenforce
[root@rhel ~]# getenforce Enforcing
三種模式的差別值得記牢:Enforcing 會真正攔截違規行為並記錄;Permissive 只記錄不攔截,常用於排查「到底是 SELinux 擋了還是別的原因」;Disabled 則完全關閉。
若要永久切換,需修改 /etc/selinux/config 的 SELINUX= 並重開機;setenforce 0/1 則只在本次開機期間有效。