Switch SELinux from Disabled to Permissive/Enforcing in Fedora

Earlier on, we have covered how to disable SELinux or set SELinux to the permissive mode in Fedora 30 / 31 / 32, RHEL or CentOS to circumvent some of the problems that one has with SELinux on. What after disabling it or setting it in permissive mode, we want to set it back to the default enforcing mode?

Set SELinux from Permissive to Enforcing

Step 1: Run these commands in terminal to open the configuration file of SELinux:

For Fedora:

sudo dnf install gedit
sudo gedit /etc/selinux/config

For RHEL, CentOS :

sudo yum install gedit
sudo gedit /etc/selinux/config

The SELinux config file will open up in the editor and it will look like the window below.

Step 2: In the editor, just change “SELINUX=permissive” to “SELINUX=enforcing”.

After editing the file, save it and restart. After the restart, your SELinux will be set to the “enforcing” mode.

Set SELinux from Disabled to Permissive/Enforcing

Step 1: We cannot change the SELinux mode directly from “Disabled” to “Enforcing”. The reason is that all the files present in the system needs to be re-labeled by SELinux first otherwise the Linux OS will not be able to access those files.

So, first, we will change the SELinux mode to “permissive”.

Run these commands in terminal to open the SELinux config file in the editor.

For Fedora:

sudo dnf install gedit
sudo gedit /etc/selinux/config

For RHEL, CentOS :

sudo yum install gedit
sudo gedit /etc/selinux/config

In the editor, change “SELINUX=disabled” to “SELINUX=permissive” as shown in the image below:

Step 2: Now, save and restart your computer. After restarting, the SELinux will re-label all the files in the system and the process will take 2-20 minutes depending on the size of data and speed of your hard drive. Do NOT restart until this relabel process is complete!!

Step 3: When your system will boot up, your SELinux mode would be set to “permissive”.

Step 4: Now, we can finally change the SELinux mode to “Enforcing”. Skip this step if you want the SELinux mode to remain at “permissive” mode.

Run these commands in the terminal:

For Fedora:

sudo dnf install gedit
sudo gedit /etc/selinux/config

For RHEL, CentOS :

sudo yum install gedit
sudo gedit /etc/selinux/config

In the editor opened, just change “SELINUX=permissive” to “SELINUX=enforcing”.

Now, restart your PC. After the restart, your SELinux will be set to “enforcing” mode.

You might also like

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.