How to check and disable Selinux in Centos7/8, RHEL 7/8
SELinux – Security-Enhanced Linux
It is a security architecture that gives you more control over the system that others can access. It was integrated into Linux in 2003. SELinux is enabled by default and you can check SELinux status with the command sestaus. SELinux usage on AVC – access vector cache. You can configure SELinux for any subject or object.
Here in this article, we will talk about how to disable SELinux. As recommended do not disable in the public domain if you do not have a firewall at the network level.
There are three modes of SELinux :
# enforcing stand for – SELinux security policy is enforced.
# permissive stand for – SELinux prints warnings instead of enforcing.
# disabled stand for – No SELinux policy is loaded.
Related Article: How to disable the firewall in RHEL 7/8 / Centos 7/8
How To Disable SELinux
Step 1- Check Status with below command
Now you can see above pic SELinux is in enforcing status. This means SELinux is active.
Step 2- Disable SELinux from below command and check the status
# setenforce 0
This will disable SELinux temporarily. For permanent you need to do entry in the configuration file.
Step 3- Make changes in the configuration file for permanent SELinux disable
There are two configuration files where we have to change it to disable or permissive as per our requirement.
File -1 – Change by below command
# vi /etc/sysconfig/selinux
Change permissive to disabled on SELINUX= *. This will disable SELinux permanently.
File -2 – Change by below command
# vi /etc/selinux/config
Do the same as done in file -1. Save both files by (press esc key):wq! Press enter.
4- Check now it will show disables in the config file.
Now at this point, you have successfully disabled SELinux and now you can check your services witch is impacted by SELinux policy. Thanks, you can share this with your colleagues and request new articles on the comment section.