Categories
Tips

Disable SELinux

Despite the power of SELinux, sometimes it was the most complicated thing to overcome when we doing daily work or when we installing new software (eg: setup a website with content outside document root). In this post, I will show you how to disable SELinux temporarily/permanently.

First of all, if you don’t know what SELinux is, here is the short introduction of SELinux from the Red Hat website:

Security-Enhanced Linux (SELinux) is a security architecture for Linux® systems that allows administrators to have more control over who can access the system.

What is SELinux? from Red Hat website

Check Status

You can check SELinux status by running the following command:

sestatus

Temporarily Disable

Sometimes, you only need to disable SELinux for a login session. Use this command:

setenforce 0

To enable SELinux again:

setenforce 1

Permanently Disable

To disable SELinux permanently, you need to have root privilege to modify the configuration file /etc/sysconfig/selinux. So we can use sudo command to edit this file as a root user:

sudo vi /etc/sysconfig/selinux
The content of the SELinux Configuration file

Press Insert on your keyboard to begin editing the file. Change the SELINUX directive to disabled as an above image. Then press Esc, type command :wq , and press Enter.

After modifying the SELinux configuration file, you need to REBOOT your computer to apply this new configuration.

After reboot, check the SELinux again you will see:

SELinux status after disabled

Those are some simple steps to disable SELinux that you can follow. If your Linux OS is using for daily basic works or regular works, you can disable SELinux right after the installation. Otherwise, please consider it carefully before do this disable.

Leave a Reply

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