How to disable selinux temporarily and permanently

How to Disable SELinux Temporarily and Permanently
Linux

How to Disable SELinux Temporarily and Permanently

Disable SELinux temporarily with setenforce or permanently through the SELinux config file, with verification commands.

SELinux configuration on a Linux server

Overview

SELinux adds an extra security layer to Linux servers. Some applications may require policy changes before they work correctly. If you need to troubleshoot quickly, you can temporarily switch SELinux to permissive mode, then decide whether a permanent change is really needed.

Check current SELinux status

sestatus

Or use:

getenforce

Disable SELinux temporarily

This changes SELinux to permissive mode until the next reboot:

sudo setenforce 0

Verify the change:

getenforce

The output should be:

Permissive

Disable SELinux permanently

Open the SELinux configuration file:

sudo nano /etc/selinux/config

Change the SELinux mode to disabled:

SELINUX=disabled

Save the file and reboot the server:

sudo reboot

Verify after reboot

sestatus

If you disabled SELinux only to troubleshoot an application, consider creating the correct SELinux policy instead of leaving it disabled permanently.