How to Enable or Reinstall SELinux on CentOS

  • Last Created On Dec 10, 2024
  • 7
0 0

Introduction

Security-Enhanced Linux (SELinux) is an enhanced security mechanism at the kernel level. Follow this guide to reinstall SELinux and reset the policy to default settings. If SELinux is not already installed, go directly to step 2.

Perform these steps as a sudo-enabled user, or root. This guide has been tested on:

  • CentOS 8
  • CentOS 7
  • CentOS 6

1. Disable and Remove SELinux

# setenforce 0

# yum remove selinux-policy\*

# rm -rf /etc/selinux/targeted /etc/selinux/config

2. Install SELinux

# yum install selinux-policy-targeted

# yum install selinux-policy-devel policycoreutils

# touch /.autorelabel; reboot

SELinux will detect the /.autorelabel file on reboot, and then relabel all files with the correct SELinux contexts. If you have many files, the instance may be unavailable for a long time.

Views: 7

Recent Articles

  • How to Install JAX with ROCm Acceleratio...
    96
  • Deploy a PyTorch Workspace on a Vultr Cl...
    71
  • Managing Backup Storage
    82
  • Automating FTP Backups in Windows Server
    71
  • Automating FTP Backups in Linux
    75

Popular Articles

  • Our General Terms & Conditions
    2630
  • Our Privacy Policy
    2474
  • Our Cookies Policy
    275
  • Our Terms of Use
    152
  • How to Install JAX with ROCm Acceleratio...
    96