
Security-Enhanced Linux (SELinux) is a mandatory access control (MAC) system that enforces strict security policies on Linux platforms. To adjust these controls, you might need to disable SELinux on Rocky Linux 9, especially if certain applications require more permissive access. SELinux is enabled by default on Rocky Linux to protect the system by limiting unauthorized interactions.
While it is not recommended to disable SELinux on production systems, some applications may require it to be disabled due to compatibility issues. This guide explains how to check the SELinux status, temporarily disable SELinux, and permanently disable SELinux on Rocky Linux 8 and 9.
SELinux operates in three different modes.
Keep the SELinux policy in enforcing mode on Rocky Linux to keep your instance secure. Disabling SELinux may expose your instance to security risks. However, if your application is not compatible with SELinux, use permissive mode before fully disabling SELinux.
Before you begin, you need to:
SE Linux is enabled by default on Rocky Linux 9. Follow the steps below to check the default SELinux status before disabling it on your workstation.
Check the SELinux status.
Your output should look like the one below.
The sestatus command outputs the system's SELinux status and Current mode. For a filtered output, use:
Follow the steps below to temporarily disable SELinux until the next reboot.
Temporarily disable SELinux.
Verify the SELinux status.
Output:
Based on the above output, the current mode is now permissive, and this change will persist until the next reboot. Reboot the system using sudo reboot and run sudo sestatus again to verify that the mode changes back to enforcing.
Permanently disabling SELinux is not recommended on Rocky Linux 9. Only disable SELinux on Rocky Linux 9 if other security mechanisms such as firewalls are enabled. Follow the steps below to permanently disable SELinux on your workstation.
Open the main SELinux configuration file using a text editor such as nano.
Find the SELINUX= directive and change its value to disabled:
Save and close the file.
Reboot the instance to apply the system changes.
Verify that SELinux is disabled after rebooting the system.
Output:
SELinux is now disabled based on the above output. The change persists across reboots, meaning SELinux will remain disabled unless you manually re-enabled again. Any new modifications to the /etc/selinux/config file require a system reboot to take effect.
Check the boot parameters to verify that SELinux is fully disabled at the kernel level.
After permanently disabling SELinux, security policies will no longer be enforced. If you need to re-enable SELinux, modify the /etc/selinux/config file and reboot your instance to apply the changes.
You have disabled SELinux on Rocky Linux 9. You temporarily disabled SELinux and permanently disabled it by modifying the main configuration file. If your application requires SELinux to be disabled, consider using permissive mode first to retain access logs. Disabling SELinux removes important security controls, as a result, ensure that alternative security measures are enabled to secure your system. Run the man selinux command for more information and command options.
0 Comments
Be the first to comment and share your perspective with the community.