How to Disable SELinux
Security-Enhanced Linux (SELinux) is a security module specifically made for the Linux kernel, which enables features that support security policies for access control, including mandatory access control (MAC).
SELinux can sometimes get in your way. Before you turn off SELinux make sure you know why you are turning it off and the security concerns you might be opening yourself up to. By disabling SELinux you will be removing a security mechanism on your system.
Disabling SELinux could lead to problems if you want to re-enable it again later. When the system runs with file labelling disable it will create files with no label – which could cause problems if the system is booted into Enforcement mode. A full re-labelling of the file system will be necessary.
This will only work in CentOS, Fedora and RedHat Enterprise Linux systems.
Check status of SElinux
You can check the status of SELinux on your system by running the following command:
# selinuxenabled && echo enabled || echo disabled
Disable SELinux Temporarily
You can disable SELinux temporarily by issuing the following command:
# echo 0 > /selinux/enforce
You can also use the setenforce command to effectively disable it, enter:
# setenforce Permissive
# setenforce 0
The above commands will switch off SELinux enforcement temporarily until the machine is rebooted.
Disable SELinux Permanently
If you would like to make it permanently, edit /etc/sysconfig/selinux using your favourite editor, enter:
# vi /etc/sysconfig/selinux
And set / update it as follows:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
Finally, reboot the system:
Your need to reboot your system in order for changes to effect.