How to Enable SELinux on a CentOS Cloud Server?

29-01-2024 03:10:57

SELinux is an enhanced security mechanism at the kernel level of the Linux operating system. This guide explains the procedures for installing and uninstalling SELinux, applicable to CentOS 8, CentOS 7, and CentOS 6 operating systems, and requires execution as the root user.

Disabling and Uninstalling SELinux

# setenforce 0
# yum remove selinux-policy\*
# rm -rf /etc/selinux/targeted /etc/selinux/config

Installing SELinux

# yum install selinux-policy-targeted
# yum install selinux-policy-devel policycoreutils
# touch /.autorelabel; reboot

Upon system reboot, SELinux checks for the /.autorelabel file and then re-labels all files with the correct SELinux context. If there are many system files, the cloud server may be in an unavailable state for an extended period. The current status of the cloud server can be monitored through the console.

For more information, refer to the official SELinux documentation.

https://wiki.centos.org/HowTos/SELinux