How to Disable SELinux on CentOS 8

SELinux or Security-Enhanced Linux is a mechanism or security module that provides access control security policies. In simple terms, it’s a feature or service used for restricting users to certain policies and rules set by the systems administrator.

In this topic, you will learn how to disable SELinux temporarily and later permanently on CentOS 8 Linux.

How to Temporarily Disable SELinux on CentOS 8

Before you start disabling SELinux on CentOS 8, it’s prudent that you first check the status of SELinux.

To do so, run the command:

# sestatus
Check SELinux Status in CentOS 8
Check SELinux Status in CentOS 8

This shows that SELinux is up and running.

To temporarily disable SELinux run the command.

# setenforce 0

Also, you can run the command.

# setenforce Permissive

Either of these commands will temporarily disable SELinux only until the next reboot.

How to Permanently Disable SELinux on CentOS 8

Now, let’s see how we can permanently disable SELinux. The configuration file for SElinux is located at /etc/selinux/config. Therefore, we need to make a few modifications to the file.

# vi /etc/selinux/config

Set the SELinux attribute to disabled as shown below:

SELINUX=disabled
Disable SELinux in CentOS 8
Disable SELinux in CentOS 8

Save and exit the configuration file and reboot your CentOS 8 Linux system using any of the commands below.

# reboot
# init 0
# telinit 0

Now check the status of SELinux using the command.

# sestatus
Verify SELinux Status in CentOS 8
Verify SELinux Status in CentOS 8

SELinux is a very crucial feature on CentOS 8 and helps in restricting unauthorized users from accessing certain services on the system.

In this guide, we demonstrated how you can disable SELinux on CentOS 8. Ideally, it’s always recommended to keep SELinux enabled with the exception of instances where you are configuring services that require SELinux to be disabled.

We hope you found this guide insightful. And that’s all for today. Your feedback is most welcome.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

James Kiarie
James Kiarie
Contributor
About the author

This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.