Sunday, October 2, 2022

How To Disable SELinux on Centos

In this section of the Linux Tutorials, we want to teach you How To Disable SELinux on Centos.

SELinux stands for Security-Enhanced Linux, which is an access control system that is built into the Linux kernel.

It is used to enforce the resource policies that define what level of access users, programs, and services have to a system.

SELinux operates in one of three modes:

  • Enforcing: SELinux controls access through policy rules.
  • Permissive: SELinux only logs actions that would have been denied.
  • Disabled: SELinux is disabled and does not create logs.

It is recommended to use SELinux in enforcing mode. If your application is not compatible with SELinux, you may need to disable SELinux on Centos completely.

Note: These commands have been tested on Centos 6, Centos 7, and Centos 8.

How To Check SELinux Status

To disable SELinux on Centos, first, you need to check the SELinux status with the following command:

sestatus

To see the current mode of SELinux status on Centos, you can use the following command:

sestatus | grep 'SELinux status\|Current mode'

In your output you will see:

Output
SELinux status:                 enabled
Current mode:                   enforcing

Now let’s see how to disable SELinux.

Disable SELinux

You can use the following command to temporarily disable SELinux:

setenforce 0

Now see the current mode of SELinux:

sestatus | grep 'SELinux status\|Current mode'

Your output should similar to this:

SELinux status:                 enabled
Current mode:                   permissive

As you can see the current mode is permissive. This will change again until the next reboot.

To permanently disable SELinux on Centos, you need to edit the SELinux configuration file.

Open the file with your favorite text editor, here we use vi:

vi /etc/selinux/config

Now find the SELINUX directive and change it to:

SELINUX=disabled

Save and close the file when you are finished.

Then, reboot your system with the following command:

shutdown -r now

After the reboot, check the status of the SELinux again:

sestatus

Your output should look like this:

Output
SELinux status:                 disabled

Conclusion

At this point, you can easily Disable SELinux on Centos.

Hope you enjoy it.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles