How To Turn Off SELinux On A CentOS 7 VPS

by | Feb 14, 2023 | Uncategorized

Enhanced Security The entire name of SELinux is Linux. It is an utility built into the Linux kernel that offers ways to enable access control security policies. According to the NSA, SELinux is a collection of programmes and patches for the Linux kernel that offer a strong and adaptable mandatory access control system. Policies for required access control are enforced by Linux kernels with SELinux. This MAC policy limits access to files, network resources, user programmes, and system functions.The ability of these applications and daemons to harm users if flawed or compromised is diminished or eliminated by limiting access to the bare minimum needed to function. The correctness of the kernel, all privileged applications, and each of their configurations determine the security of a Linux system without SELinux support. Any one of these weaknesses could lead to the system’s overall security being compromised.

Why Turn Off SELinux?

This functionality is enabled by default in fresh Linux installations. Some apps are unable to access secured networks and files as a result. Full access to the system’s files and resources is necessary for running programmes like cPanel and Plesk. These processes are terminated by SElinux as a security precaution because they have the power to alter the system. But you are aware that these tools are web hosting control panels, and for them to function properly, SELinux needs to be modified.

SELinux has three modes:

    • Enforcing: SELinux grants access in accordance with its policy regulations.
    • Permissive: Only actions that would have been rejected if SELinux was operating in enforcing mode are logged.
    • Disabled: There is no loaded SELinux policy.

On CentOS 7, how can I disable SELinux?

We will first look at the SELinux situation. Enter the command on the terminal to check the mode’s state.

# sestatus

As we can see, the working mode is Enforced with targeted policy rules, and the status is currently enabled.

Turn Off SELinux Momentarily

To temporarily change the mode to permissive, use the provided command. This command solely modifies the runtime session’s mode.

# setenforce permissive

Check the status of the current mode after entering the command to see if permissive has been changed. Restarting or logging out will return the mode to enforcing.

Permanent SELinux disable

Editing the SELinux configuration file is required to permanently disable SELinux. Enter the given command on the terminal to accomplish that. The conf file will be read-only after you do this.

# vi /etc/sysconfig/selinux

To modify the file and set it to disabled, press I. Press WQ to save your modifications to the file and close the editor after that.

Recheck the situation.

# sestatus


A fantastic security tool is SELinux. It can, however, be a little upsetting and inconvenient for some programmes. We learned about SELinux and its various modes in this guide. We also learnt how to permanently and temporarily disable SELinux. It’s all done for today.

Read Our Next Articles How To Set Up A New Website Using Windows Server With IIS