Home / How to disable SELinux in CentOS Linux and AlmaLinux?

How to disable SELinux in CentOS Linux and AlmaLinux?

Disabling SELinux is not advised.

Only turn off SELinux if your regulatory framework permits you to omit some measures of security reporting and enforcement.

If SELinux is later turned on, files made while disabled will not have the proper labels.

If you decide to turn SELinux back on, you'll need to rename all of your files. It takes a long time to complete this task.

Temporarily switching SELinux to permissive mode can help with troubleshooting issues. Policies for SELinux will remain active.

Even though access attempts that do not comply with the policies will be logged, they will not be denied.

CentOS 9 / AlmaLinux 9

Install the grubby package if not already installed.

# dnf install grubby
Configure the boot loader to add selinux=0 to the kernel command line.
# grubby --update-kernel ALL --args selinux=0

Reboot server.

# reboot
To re-enable SELinux run the following command.
# grubby --update-kernel ALL --remove-args selinux

CentOS 6, 8, 7 / AlmaLinux 8

Edit the /etc/selinux/config file and change SELINUX=enforcing to SELINUX=disabled and then reboot server.
# reboot
In the second method, install the grubby package as follows.
# yum install grubby
Configure the boot loader to add selinux=0 to the kernel command line.
# grubby --update-kernel ALL --args selinux=0

Reboot the server as follows.

# reboot

Leave a Reply