Disable SELinux in CentOS 7


This article will provide the steps to disable SELinux in CentOS 7. SELinux is a security enhancement to Linux which allows users and administrators more control over access control.

The following guide requires root user access.

Temporarily Disable SELinux

To temporarily disable SELinux in CentOS 7, perform the following steps:

  1. From the command line, login as root user.
  2. Run the command:
    setenforce 0
  3. Check the status of SELinux with the following command:
    sestatus

SELinux has now been disabled for the current session.

Permanently Disable SELinux

To permanently disable SELinux in CentOS 7, perform the following steps:

  1. From the command line, login as root user.
  2. Open the /etc/selinux/config file with your preferred text editor:
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    SELINUX=enforcing
    # SELINUXTYPE= can take one of these two values:
    #       targeted - Targeted processes are protected,
    #       mls - Multi Level Security protection.
    SELINUXTYPE=targeted
  3. Change the SELINUX value to disabled:
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    SELINUX=disabled
    # SELINUXTYPE= can take one of these two values:
    #       targeted - Targeted processes are protected,
    #       mls - Multi Level Security protection.
    SELINUXTYPE=targeted
  4. Reboot your CentOS server with the following command:
    reboot
  5. When the server finishes booting, verify SELinux status with the command:
    sestatus

SELinux has now been disabled on your CentOS 7 server.

  • disable selinux, selinux
  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

View Server PHP Environment with phpinfo.php

The phpinfo() function outputs a huge amount of information about the system you're using, such...

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...

508 Resource Limit is Reached

If your website is on a cPanel hosting account, you may have noticed the following error message:...