How to Disable SELinux on RHEL 7/CentOS 7/Oracle Linux 7

Security-Enhanced Linux (SELinux) is a Linux kernel security module that provides a mechanism for enforcing mandatory access control (MAC) policies. It is designed to enhance the overall security of your Linux system by restricting processes and users to the minimum privileges necessary for their tasks. While SELinux can significantly improve your system’s security posture, there are situations where you may need to disable it temporarily or permanently, such as during troubleshooting or when deploying specific applications that are not compatible with SELinux.

In this guide, we will demonstrate how to disable SELinux on RHEL 7, CentOS 7, and Oracle Linux 7. Following these steps will help you disable SELinux safely and effectively, ensuring that your system operates as intended without the restrictions imposed by SELinux. It is crucial to understand the security implications of disabling SELinux and to re-enable it whenever possible to maintain the highest level of system security.

See also  How to Add a New Hard Disk Without Rebooting on CentOS 7/ RHEL 7

Step 1: Check SELinux Status

Before making any changes, it is essential to check the current SELinux status on your system. Use the following command to do so:


This command will display the SELinux status, mode, and policy being used.

# sestatus

SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

Step 2: Temporarily Disable SELinux

To temporarily disable SELinux until the next system reboot, use the following command:

sudo setenforce 0

You can re-enable SELinux without rebooting by running:

sudo setenforce 1

Keep in mind that these changes are temporary and will not persist after a reboot.

See also  How to enable PHP MBString Extension on Ubuntu?

Step 3: Permanently Disable SELinux

To permanently disable SELinux, follow these steps:

Open the SELinux configuration file using your preferred text editor:

sudo nano /etc/selinux/config

Change the “SELINUX” line 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.
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.

Save the changes and exit the text editor.

Reboot your system for the changes to take effect:

sudo reboot

After the system reboots, SELinux should be permanently disabled.

# sestatus

SELinux status:                 disabled

Commands Mentioned:

  • sestatus – A command to check the current SELinux status, mode, and policy.
  • setenforce – A command to temporarily enable or disable SELinux enforcement.
  • nano – A user-friendly text editor for the command line.
  • reboot – A command to restart the system.
See also  How to Find Files in Linux


By following this guide, you have successfully disabled SELinux on RHEL 7, CentOS 7, and Oracle Linux 7, either temporarily or permanently. Disabling SELinux can be necessary in certain situations, such as troubleshooting or deploying specific applications. However, it is essential to remember the security implications of disabling SELinux and to re-enable it whenever possible to maintain a secure system.

We invite you to share your thoughts, comments, and suggestions for improvements to this guide. Your feedback is invaluable in helping us provide the most accurate and useful information possible.


Leave a Reply

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