Disable SELinux or Set it to Permissive mode in Fedora, RHEL, or CentOS

SELinux can interfere even in the normal functioning of some of the apps in Fedora/RHEL/CentOS. For example, if you install apache server and PHP on your computer and try to open a PHP file containing the following code, then instead of your PHP info which you would expect to see, what you will really see on the screen is “Access is Denied.“.

<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>

To make it work, either you can make SELinux ignore such operations but this is a cumbersome and time-consuming process and thus it’s recommended that you set the SELinux to “permissive” mode or “disable” it entirely.

In permissive mode, SELinux will only show and log warnings but will not block any operations. If disabled, then it will not even show or log any warnings or block any operations.

Run these commands in the terminal window to open the “config” files of SELinux :

For Fedora :

sudo dnf install gedit
sudo gedit /etc/selinux/config

For RHEL, CentOS :

sudo yum install gedit
sudo gedit /etc/selinux/config

To make SELinux run in permissive mode, simply set “selinux=permissive” in the file and if you want to disable SELinux, then set “selinux=disabled” as shown below. After editing this file save it and then restart your computer.

NOTE: If you disable SELinux, you won’t be able to set it to “permissive” or “enforcing” without making your OS unbootable. Though you can make it work again but the procedure for that is complicated and I won’t discuss it here as it is beyond the scope of this tutorial. So, set it only to “permissive” in case if there is any chance that you may want to revert to “enforcing” later on.

You might also like

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.