Tutorials  /  Linux Basics

How to Disable SELinux on Rocky Linux 9 (Temporary & Permanent)

Ccentron Redaktion · August 2025 ·4 min read ·Linux Basics, Tutorial

Security-Enhanced Linux (SELinux) implements a mandatory access control (MAC) framework that strictly enforces security rules across Linux systems. On Rocky Linux 9, SELinux is activated by default to prevent unauthorized system activities. However, certain software may not function properly under these restrictions, which could necessitate turning off SELinux temporarily or permanently.

Although it's generally advised to keep SELinux active in production settings, some compatibility problems may require deactivation. This guide outlines how to check the current SELinux status and provides instructions to disable it either temporarily or permanently on Rocky Linux 8 and 9.

SELinux Operating Modes

SELinux supports three distinct operational modes:

  • Enforcing: Applies all security policies. Recommended for production environments.
  • Permissive: Logs policy violations without enforcing restrictions. Helpful for testing and debugging.
  • Disabled: Turns off all SELinux controls. Not recommended as it removes all enforcement mechanisms.

Note: Keeping SELinux in enforcing mode is the best way to secure your Rocky Linux system. Use permissive mode if your application is not compatible before choosing to fully disable SELinux.

VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Requirements

Before starting, ensure you have:

  • A Rocky Linux 9 system
  • Non-root user access with sudo privileges

Checking SELinux Status

On Rocky Linux 9, SELinux is enabled by default. To verify its current status, execute the command below:

Console
$ sudo sestatus

The expected output includes the following lines:

  • SELinux status: enabled
  • Current mode: enforcing

To display only the status and mode, use:

Console
$ sudo sestatus | grep 'SELinux status\|Current mode'

Temporarily Turning Off SELinux

To disable SELinux temporarily—until the next system reboot—use the following command:

Console
$ sudo setenforce 0

To confirm the change:

Console
$ sudo sestatus | grep 'SELinux status\|Current mode'

Output:

  • SELinux status: enabled
  • Current mode: permissive

This temporary mode remains in effect only until the next reboot. After restarting with sudo reboot, the mode reverts to enforcing unless changed again.

Permanently Disabling SELinux

Disabling SELinux permanently should only be considered when other security layers like firewalls are in place. To proceed:

  1. Open the SELinux config file using a text editor:
Console
$ sudo nano /etc/selinux/config

2. Locate the line with SELINUX= and change it to:

Console
# 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

3. Save and exit the file.

4. Reboot your machine:

Console
$ sudo reboot

5. After rebooting, confirm that SELinux is turned off:

Console
$ sudo sestatus

You should now see:

  • SELinux status: disabled

This confirms that SELinux is completely disabled, and the change will remain even after reboots unless manually reversed.

Confirming Kernel-Level SELinux Deactivation

To ensure that SELinux has been disabled at the kernel level, run:

Console
$ cat /proc/cmdline | grep selinux

Note: Once SELinux is permanently turned off, no security rules will be enforced. If needed, re-enable it by editing the config file and rebooting your system.

Conclusion

You’ve now successfully deactivated SELinux on Rocky Linux 9, both temporarily and permanently. Before opting to fully disable it, try using permissive mode to preserve audit logs. Disabling SELinux reduces your system’s built-in defenses, so always ensure other protective measures are in place. To learn more, refer to the manual by running man selinux.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren