Disabling SELinux
Only the root user can disable SELinux. Common users can only view the SELinux status.
Disabling SELinux Temporarily
The setting becomes invalid after the server is rebooted. When the tool is used, service exceptions may occur.
- Query the SELinux status.
1sestatus
If the value of Current mode is enforcing, the SELinux enforcing mode is enabled.
- Set the SELinux mode to permissive.
1setenforce 0
- Query the SELinux status again.
1sestatus
If the value of Current mode is permissive, the SELinux enforcing mode is disabled temporarily.
- (Optional) Restore the enforcing mode.
If the SELinux enforcing mode is required, you can restore it after using the tool.
1setenforce 1
Set the SELinux mode to enforcing.
- (Optional) Query the SELinux status.
1sestatus
If the value of Current mode is enforcing, the SELinux enforcing mode is re-enabled.
Disabling SELinux Permanently
- Query the SELinux status.
1sestatus
If SELinux status is enabled, SELinux is enabled.
- Modify the /etc/selinux/config file.
- Open the /etc/selinux/config file.
1vi /etc/selinux/config - Press i to enter the insert mode and change SELINUX=enforcing to SELINUX=disabled.
- Press ESC, type :wq!, and press Enter to save the file and exit.
- Open the /etc/selinux/config file.
- Reboot the server.
1reboot
Exercise caution when rebooting the server.
- Query the SELinux status again.
1sestatus
If SELinux status is disabled, SELinux is disabled.
- (Optional) Restore SELinux to the original status.
- Open the /etc/selinux/config file.
1vi /etc/selinux/config - Press i to enter the insert mode and change SELINUX=disabled to SELINUX=enforcing.
- Press ESC, type :wq!, and press Enter to save the file and exit.
- Open the /etc/selinux/config file.
- (Optional) Restart the server.
1reboot
- (Optional) Query the SELinux status again.
1sestatus
If SELinux status is enforcing, SELinux is re-enabled.