clear sudo cp /etc/selinux/config /etc/selinux/config.bk sudo sed -i '/^#/d' /etc/selinux/config sudo sed -i '/^$/d' /etc/selinux/config SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2) echo Current Status: $SELinuxStatus
clear # SELinux - Enforcing sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=enforcing|" /etc/selinux/config SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2) echo New Status: $SELinuxStatus
clear # SELinux - Permissive sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=permissive|" /etc/selinux/config SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2) echo New Status: $SELinuxStatus
clear # SELinux - Disable sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=disabled|" /etc/selinux/config SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2) echo New Status: $SELinuxStatus
A couple ways to do this, I like this method below most as it bundles some stuff above into a nice package.
clear sudo cp /etc/selinux/config /etc/selinux/config.original sudo sed -i '/^#/d' /etc/selinux/config sudo sed -i '/^$/d' /etc/selinux/config SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2) echo "Current Status: $SELinuxStatus" sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=permissive|" /etc/selinux/config SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2) echo "New Status: $SELinuxStatus" sudo shutdown -r now
Reference: https://www.crypt.gen.nz/papers/how-to-disable-selinux/
Originally Posted on July 21, 2016
Last Updated on December 21, 2017
Last Updated on December 21, 2017
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.