Disabling SELinux Temporarily or Permanently on CentOSRHEL

Disabling SELinux Temporarily or Permanently on CentOS/RHEL

Disabling SELinux on CentOS/RHEL helps your applications to function normally and support the security mechanism of SELinux. Since SELinux is enabled by default, this article will present Disabling SELinux Temporarily or Permanently on CentOS/RHEL. As the most secure operating system, Linux implements security features such as Security-Enhanced Linux (SELinux) to let admins access control.

This Linux kernel security feature enables sysadmins to let their desired users and apps access resources. Join us with this guide to review all the easy required steps to check the status of SELinux and disable it on CentOS if it is enabled.

Prerequisites to Disable SELinux on CentOS

To let this tutorial works correctly, provide the options below and move on.

  • A system running CentOS VPS.
  • A non-root user with sudo privileges.
  • Linux Terminal.

Disabling SELinux Temporarily or Permanently on CentOS/RHEL

As you learned in the SELinux article, it monitors system access and imposes restrictions in cases where security is compromised. So, to let the apps function normally, you need to disable or turn off SELinux. Disabling SELinux Temporarily or Permanently on CentOS/RHEL is really easy and requires a few commands.

Firstly, let’s see how to check the status of SELinux on your CentOS system. To do this simply run:

$ sestatus

While you are reading ”enabled” in the output for the status of SELinux, you are ready to disable it. But depending on your proposes, you can do it temporarily or permanently. In the end, you have learned both these manners. Stay with us.

How to Disable SELinux on CentOS/RHEL Temporarily

To disable SELinux temporarily on CentOS/RHEL, open the terminal and run the command below:

# echo 0 > /selinux/enforce

Also, you can use the setenforce tool as an alternative:

# setenforce 0

Run the following command to put SELinux on Permissive mode which is the disabled mode.

# setenforce Permissive

Since the above commands work until the next root and are only for your current session. So, to disable SELinux permanently move to the next section to learn to disable it permanently.

How to Disable SELinux on CentOS/RHEL Permanently

Open your favorite text editor and open the file /etc/sysconfig/selinux.

# nano /etc/sysconfig/selinux

To change the SELINUX to disabled mode, run:

SELINUX=disabled

Save and exit the file. To let the changes take effect, reboot your system by typing the command below:

$ sudo reboot

To make sure SELinux is disabled and removed successfully, run the commands below:

$ getenforce
$ sestatus

Once you see the ”disabled” for SELinux status, you’re all set.

Conclusion

In this article, you reviewed Disabling SELinux Temporarily or Permanently on CentOS/RHEL. The existing commands also work on Fedora. Disabling SELinux is not recommended and must be done under security knowledge to not occur problems on your Linux server. If you are interested in learning Linux security features, refer to our related articles on the OperaVPS blog.

Leave a Reply

Your email address will not be published. Required fields are marked.