Rate This Document
Findability
Accuracy
Completeness
Readability

Disabling SELinux

Disabling SELinux Temporarily

The setting becomes invalid after the server is rebooted. When the tool is used, service exceptions may occur.

  1. Query the SELinux status.
    1
    sestatus
    

    If the value of Current mode is enforcing, the SELinux enforcing mode is enabled.

  2. Set the SELinux mode to permissive.
    1
    setenforce 0
    
  3. Query the SELinux status again.
    1
    sestatus
    

    If the value of Current mode is permissive, the SELinux enforcing mode is disabled temporarily.

  4. (Optional) Restore the enforcing mode.

    If the SELinux enforcing mode is required, you can restore it after using the tool.

    1
    setenforce 1
    

    Set the SELinux mode to enforcing.

  5. (Optional) Query the SELinux status.
    1
    sestatus
    

    If the value of Current mode is enforcing, the SELinux enforcing mode is re-enabled.

Disabling SELinux Permanently

  1. Query the SELinux status.
    1
    sestatus
    

    If SELinux status is enabled, SELinux is enabled.

  2. Modify the /etc/selinux/config file.
    1
    vi /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.

  3. Reboot the server.
    1
    reboot
    

    Exercise caution when rebooting the server.

  4. Query the SELinux status again.
    1
    sestatus
    

    If SELinux status is disabled, SELinux is disabled.

  5. (Optional) Restore SELinux to the original status.
    Modify the /etc/selinux/config file.
    1
    vi /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.

  6. (Optional) Restart the server.
    1
    reboot
    
  7. (Optional) Query the SELinux status again.
    1
    sestatus
    

    If SELinux status is enforcing, SELinux is re-enabled.