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:
- From the command line, login as root user.
- Run the command:
setenforce 0
- 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:
- From the command line, login as root user.
- 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
- 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
- Reboot your CentOS server with the following command:
reboot
- When the server finishes booting, verify SELinux status with the command:
sestatus
SELinux has now been disabled on your CentOS 7 server.