How to Disable SELinux?
SELinux (Security Enhanced Linux) is a Linux kernel security module that allows administrators and users more control over access controls. It allows access based on SELinux policy rules. In Almalinux, SELinux is enabled and in enforcing mode by default.
SELinux policy rules specify how processes and users interact with each other as well as how processes and users interact with files. When no SELinux policy rule explicitly allows access, such as for a process opening a file, access is denied. SELinux has three modes:
- Enforcing: SELinux allows access based on SELinux policy rules.
- Permissive: SELinux only logs actions that would have been denied if running in enforcing mode.
- Disabled: No SELinux policy is loaded.
Disable SELinux on Almalinux
You will need a user with with sudo privileges in order to perform this task and disable SELinux. Check the status of SELinux first to make sure it is not disabled.
You can check the status of SELinux using the following command at terminal.
sestatus
Output example showing SELinux in enforcing state (enabled)
SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 31
The output above shows that SELinux is enabled and is set to enforcing mode. Now follow the next step to disable SELinux.
Step by Step Guide to Disable SELinux
To permanently disable SELinux on your Almalinux system, follow the steps below:
Edit the /etc/selinux/config file to set the SELINUX parameter to disabled, and then reboot the server. The contents of the /etc/selinux/config file should resemble the following example:
# 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 # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
Make sure that there is only one enable SELINUX=disabled parameter, a parameter is enabled by removing "#" sign before it.
Save the SELinux configuration file and reboot the system.
reboot
Once the system has rebooted, check the status of SELinux.
sestatus
Output example showing SELinux in disabled state.
SELinux status: disabled
You have successfully disabled SELinux.
Related Categories:
Articles Sharing the Same Category
- How to Generate OpenVPN Client Configuration Files?
- How to Change ProFTPD Passive Ports and Make the Configuration Persistent?
- How to SFTP to a server with a private key?
- How To Set Up and Configure an OpenVPN Server on Linux?
- Import SQL file using the command line in MySQL?