===== Ubuntu - SELinux - Turn off SELinux =====
Type the following command:
echo 0 >/selinux/enforce
You can also use the setenforce command to effectively disable it, enter:
setenforce Permissive
OR
setenforce 0
The above commands will switch off SELinux enforcement temporarily until the machine is rebooted.
If you would like to make it permanently, edit /etc/sysconfig/selinux, enter:
vi /etc/sysconfig/selinux
And set / update it as follows:
SELINUX=disabled
Save and close the file.
The above will only work in CentOS, Fedora and RedHat Enterprise Linux systems.
For all other Linux distros edit your boot loader config file (LILO or GRUB boot loader config file such as /boot/grub/grub.conf).
Find the kernel line, append enforcing=0 at the end:
title Red Hat Enterprise Linux Server (2.6.18-194.26.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.26.1.el5 ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 enforcing=0
initrd /initrd-2.6.18-194.26.1.el5.img
Finally, reboot the system:
reboot
----
===== Grub =====
SELinux is often also configured in the grub bootup configuration.
If you can’t locate the /etc/selinux/config file on your system, you can pass disable SELinux by passing it as parameter to the Grub Boot Loader as shown below.
Search **/boot/grub/grub.conf** file using grep and make sure the following line **DOES NOT** appears:
egrep -i 'selinux=0|enforcing=0' /boot/grub/grub.conf
If you found lines with selinux=0 or enforcing=0, remove them and save the changes.
Example:
# cat /boot/grub/grub.conf
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Enterprise Linux Enterprise Linux Server (2.6.18-92.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-92.el5PAE ro root=LABEL=/ rhgb quiet selinux=0
initrd /boot/initrd-2.6.18-92.el5PAE.img
title Enterprise Linux Enterprise Linux Server (2.6.18-92.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet selinux=0
initrd /boot/initrd-2.6.18-92.el5.img
----
Reboot the server:
reboot