How to Disable SELinux Permanently or Temporarily

Linux is considered as one of the safest operating systems that you can use right now, because of its very well-known security implementation features such as SELinux (Security-Enhanced Linux).

For starters, SELinux is described as a mandatory access control (MAC) security structure that is run on the kernel. SELinux offers a way to run a number of security policies that should not be implemented effectively by "System Administrators".

How to disable SELinux permanently or temporarily

When you install "RHEL / CentOS" or some derivatives, SELinux features or services are activated by default, because of this some applications on your system may not really support this security mechanism. Therefore, to make such an application function normally, you must disable SELinux.

Attention : If you don't want to disable SELinux, then you should read the following article to apply some mandatory access controls on files and services in order to function properly.

In this guide, I will tell you the steps you can follow to check SELinux status and also disable SELinux in CentOS / RHEL and Fedora, if it is activated.

How I Can Disable SELinux on Linux ?

The first thing to do is check the SELinux status on your system, and you can do this by running the following command :

$ sestatus

How to disable SELinux permanently or temporarily

Next, to disable SELinux on your system, this can be done temporarily or permanently depending on what you want to achieve.

Temporarily disable SELinux
# echo 0 > /selinux/enforce

Or, you can use Setenforce.

# setenforce 0

Additionally, use the Permissive option instead of 0

# setenforce Permissive

The above methods will only work until the next reboot, therefore to permanently disable SELinux, move to the next section.

Disable SELinux Permanently

To permanently disable SELinux, use your favorite text editor to open the / etc / sysconfig / selinux file as follows :

# vi / etc / sysconfig / selinux

How to disable SELinux permanently or temporarily

Then change the direction SELinux = enforcing to SELinux = disabled as shown in the image below.

SELINUX=disabled
How to disable SELinux permanently or temporarily

Then, save and exit the file, for the changes to take effect, you need to reboot your system and then check the SELinux status using the sestatus command as shown:

$ sestatus

How to disable SELinux permanently or temporarily


In conclusion, through simple steps you can follow to disable SELinux on CentOS / RHEL and Fedora. Good luck.

Other Articles :

Post a Comment

Previous Post Next Post