Skip to main content
This lesson explains SELinux booleans and how to use them to adjust SELinux policy behavior without rewriting or rebuilding policies. SELinux booleans let administrators toggle specific policy rules on or off so services can be granted additional capabilities when needed — without disabling SELinux entirely. For example, a web server that is normally prevented from initiating outbound network connections can be allowed to do so by enabling the appropriate boolean.
Use SELinux booleans to grant controlled exceptions for services rather than turning off SELinux.

Quick overview

  • SELinux booleans toggle parts of the policy at runtime.
  • Runtime-only changes apply immediately but are lost at reboot unless persisted.
  • Two common tools:
    • setsebool — change runtime state (optionally persist with -P).
    • semanage boolean — view and change persistent settings with descriptions.

Checking SELinux mode

Confirm SELinux is running and in enforcing mode:

Listing all booleans

List all SELinux booleans and their current runtime state with getsebool -a:
To find booleans related to a specific service (for example, HTTPD), filter the output with grep:

Changing booleans with setsebool

To change a boolean at runtime, use setsebool followed by the boolean name and on or off. By default, this affects only the running system and will be lost after a reboot. Examples (runtime-only):
To make the change persistent across reboots when using setsebool, add the -P (uppercase P) option:
Validate the current runtime state with:
Remember: setsebool without -P changes only the current runtime state. Use -P to persist changes across reboots.

Inspecting booleans and descriptions with semanage

If you prefer a more descriptive listing that includes a short description and both runtime and persistent states, use:
In the semanage output, the first value in parentheses is the runtime state and the second is the persistent state (what will be applied after a reboot). You can filter semanage output the same way as getsebool:

Changing booleans persistently with semanage

To modify a boolean persistently using semanage, use the -m option together with --on or --off. For example, to enable httpd_enable_homedirs persistently:
To disable it persistently:
Validate with semanage boolean -l | grep httpd_enable_homedirs or getsebool -a | grep httpd_enable_homedirs to confirm both runtime and persistent states.

Common commands (cheatsheet)

Summary

  • SELinux booleans let you toggle policy behavior without editing policies.
  • Use getsebool -a to list runtime boolean states and getsebool -a | grep <term> to filter.
  • Use setsebool <boolean> on|off to change the runtime state; add -P to persist with setsebool.
  • Use semanage boolean -l to list booleans with descriptions and both runtime and persistent values.
  • Use semanage boolean -m --on|--off <boolean> to change the persistent state via semanage.
You now know how to view and modify SELinux booleans to adjust service behavior safely, without disabling SELinux.

Watch Video