- Modifying SELinux settings at boot time using Boolean values.
- Diagnosing and resolving routine SELinux policy violations.
Using Boolean Values to Modify SELinux Settings at Boot Time
We’ll start by modifying SELinux behavior directly from the GRUB boot screen of a RHEL machine.
1. Booting in Permissive Mode
Appendingenforcing=0 will start SELinux in permissive mode while still applying the appropriate SELinux labels. This method is the Red Hat recommended approach to boot in permissive mode. For example:
2. Disabling SELinux Support at Boot
Alternatively, you can disable SELinux entirely during boot by appendingselinux=0 to the kernel command line. When this parameter is used, no SELinux components will be loaded by the kernel. A subsequent boot without this parameter will trigger an automatic filesystem relabel.
3. Enabling Auto Relabel
You can force a full filesystem relabel by appendingautorelabel=1. This is equivalent to creating the /etc/selinux/auto_relabel file and rebooting.
Diagnosing and Addressing Routine SELinux Policy Violations
Once the system has booted, log in to your RHEL system.
Example: Changing the HTTPD Port
A typical issue arises when you modify the default port for the Apache HTTPD service. First, verify HTTPD is installed, then inspect the Apache configuration file to locate theListen directive.

journalctl -xe may point out that SELinux is preventing HTTPD from binding to port 88:
my-httpd is installed, restart Apache:
Restoring Default File Contexts for Apache
Another common issue occurs when file contexts do not align with SELinux expectations, particularly when Apache’sDocumentRoot is changed to a non-default directory.
In this scenario, modify the Apache configuration file to update the DocumentRoot. For example, change it to /kodedu:

http://127.0.0.1:88/kodekloud.html, you might receive a “Forbidden” error. This error indicates that SELinux is denying access because the file contexts are incorrect. Check the current SELinux labels with:
/kodedu often have a generic context (e.g., default_t) instead of the required httpd_sys_content_t.
To resolve this, use the
semanage command to assign the proper context.Summary
In this lesson, you learned how to:- Use Boolean values at boot time to modify SELinux behavior.
- Diagnose SELinux policy violations through
systemctlandjournalctl. - Generate and apply local SELinux policy modules.
- Correct file contexts using
semanageandrestoreconto resolve access issues with Apache.