Script to disable SeLinux

Many time we have faced an issue because SeLinux enabled on server after rebooting the server, to resolve the issue
permanently add the following script in the rc.local boot file, so that by default SeLinux will be disabled.

Login into the server and create the new script file.

nano /root/selinux.sh

insert the following code in the selinux.sh file

if [ -f “/usr/sbin/getenforce” ] && [ `id -u` = 0 ] ; then
selinux_status=`/usr/sbin/getenforce`
/usr/sbin/setenforce 0 2> /dev/null
fi

Open the file /etc/rc.local and add the following line , so that it will execute once server rebooted.

sh /root/selinux.sh

About Anant 384 Articles
Senior technical writer