Search
Close this search box.

How to Disable SELinux on CentOS

Table of Contents

How to Disable SELinux on CentOS

 

SE Linux is the acronym for Security-Enhanced Linux, which controls access to Linux systems built into the kernel. Typically, it determines the number of access users, programs, or services have to a plan. According to its default enforcement mode, SELinux prevents unauthorized access to any resource by logging all attempts. This principle, which aims to give as little power as possible to a user or program, requires explicit permission from these individuals to use files, directories, sockets, and other resources.

 

Before we get started, let me give you a quick overview of the SELinux modes,

 

There are three modes in which SELinux operates:

 

1) Enforcing: SELinux manages access via policy rules.

 

2) Permissive: SELinux only logs actions if they would have been forbidden.

 

3) Disabled: SELinux is disabled, and no logs are generated.

 

SELinux should be used in the enforcing mode. When an application is incompatible with SELinux, it may be necessary to remove it entirely. We cover this procedure here. 

Let’s start

 

Step 1:  Check SELinux Status

 

Use the following command:

 

sudo sestatus

 

Find the lines relevant to this tutorial with grep:

 

# sudo sestatus | grep 'SELinux status\|Current mode'

SELinux status:                 enabled
Current mode:                   enforcing

 

Step 2: Temporarily Disable SELinux

 

 

sudo setenforce 0

 

Check again,

 

# sudo sestatus | grep 'SELinux status\|Current mode'
SELinux status: enabled Current mode: permissive

 

Please note that the Current mode is now permissive. Note that this change is only valid until the next reboot.

 

 

Step 3: Permanently Disable SELinux

 

 

You can disable SELinux and make it persistent across reboots by editing /etc/selinux/config.

 

sudo nano /etc/selinux/config

 

Specify permissive or disabled for SELINUX directive.  

 

SELINUX=disabled

 

Once the file is saved and exited, restart your system,

 

sudo shutdown -r now

 

Then, check the status.

 

# sudo sestatus
SELinux status: disabled

 

 

That’s it!

 

 

 

 

 

 

VPSie is looking forward to embarking on a new journey with you!

 

 

Understand NVMe (Non-Volatile Memory Express)

 

SELinux (Security-Enhanced Linux) is a security feature built into the Linux kernel that provides access control security policies. While it is a powerful security feature, it can sometimes interfere with legitimate operations such as running certain applications or accessing certain files. In such cases, disabling SELinux can be a solution.

To check if SELinux is enabled on your CentOS system, you can use the sestatus command. If SELinux is enabled, it will display the current mode (enforcing, permissive, or disabled) and other related information.

There are three modes of SELinux: enforcing, permissive, and disabled. The enforcing mode is the default mode that enforces SELinux policies, the permissive mode allows SELinux policies to be logged without enforcing them, and the disabled mode completely disables SELinux.

To temporarily disable SELinux, you can run the command setenforce 0. This will set SELinux to permissive mode, which allows SELinux policies to be logged without enforcing them.

To permanently disable SELinux, you can modify the SELinux configuration file located at /etc/selinux/config. Open the file in a text editor and change the value of the SELINUX parameter to disabled. Save the file and reboot the system for the changes to take effect.

Disabling SELinux can reduce the security of your CentOS system, so it is not recommended unless it is absolutely necessary. Instead of disabling SELinux, you can modify the SELinux policies to allow the legitimate operations that are being blocked.

You can use the semanage and setsebool commands to modify SELinux policies on CentOS. The semanage command allows you to manage SELinux policy modules, while the setsebool the command allows you to modify SELinux boolean values that control various aspects of SELinux policy.

Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Fast and Secure Cloud VPS Service

Try FREE
For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.