Advanced Package: libselinux-utils / policycoreutils

getenforce / setenforce

Check or change the current SELinux mode.

Syntax

getenforce | setenforce [Enforcing|Permissive]

Description

getenforce reports whether SELinux is Enforcing, Permissive or Disabled; setenforce temporarily switches between Enforcing and Permissive at runtime, which is a common first troubleshooting step when SELinux appears to be blocking something.

Examples

getenforce
Show the current SELinux mode
sudo setenforce 0
Temporarily switch to Permissive mode (logs denials, does not block)
sudo setenforce 1
Switch back to Enforcing mode
RHEL-based systems only. A permanent change requires editing /etc/selinux/config.

Applies to

RHEL CentOS / Rocky / AlmaLinux Fedora