SELinux is a mandatory access control (MAC) system installed and enabled by default when you install RHEL/CentOS/Fedora Linux. It allows system administrators to easily configure security policies that would have been otherwise difficult to implement from scratch. But some applications may run into conflict with SELinux and stop running properly. So in such cases you may need to disable SELinux from your system. In this article, we will look at how to disable SELinux in CentOS. You can follow the same steps to disable SELinux from RHEL/Fedora/SUSE Linux systems.
How to Disable SELinux in CentOS
Here are the steps to disable SELinux from your system.
1. Check SELinux status
First it is advisable to check the status of SELinux on your system. Open terminal and run the following command to view its status.
There are two ways to disable SELinux – termporarily and permanently. We will look at both these methods one by one.
2. Disable SELinux Temporarily
In this case, SELinux will be disabled only until the next system reboot. When you reboot the system, SELinux will be automatically re-enabled. There are several ways to disable SELinux temporarily. You can run any of the following commands to disable SELinux temporarily.
$ echo 0 > /selinux/enforce $ setenforce 0 $ setenforce Permissive
3. Disable SELinux Permanently
To permanently disable SELinux, open /etc/sysconfig/selinux in a text editor.
$ vi /etc/sysconfig/selinux
Then change SELinux = enforcing to SELinux = disabled.
Save and exit the file to apply changes. Check SELinux status with the following command.
You will see the following output.
SELinux status : disabled
That’s it. In this article, we have learnt how to disable SELinux temporarily as well as permanently. You can use either of the approaches depending on your requirement.