Home Linux ServerLinux Fundementals How to disable SELinux on CentOS 7

How to disable SELinux on CentOS 7

by Thạch Phạm

SELinux is a security part of Server/VPS. However, in many cases when you want to install software, you will have to disable SELinux to be able to install it. For example, I need to install FASTPANEL as shown below, when I have SELinux I will not be able to install it.

disable SELinux on CentOS 7

And in this article, AZDIGI will guide you to disable SELinux on CentOS 7.

What is SELinux?

SELinux is a security feature that restricts access to certain modules on the kernel. With CentOS 7 when installed, SELinux is enabled by default. And SELinux is also installed on other Linux OS like Debian. SELinux is managed through principles known as “policies”, which restrict or allow certain applications to access critical system components.

Here are the statuses of SELinux:

  • The Enforcing state blocks all unauthorized access. In this state, SELinux is enabled.
  • Permissive SELinux status will only warn, not block access.
  • The Disable SELinux status will be disabled and all unauthorized access will be possible and no warning will be given.

So we know how SELinux works. And know whether to disable it or not.

Disable SELinux on CentOS 7

With SELinux, you will have two options that are temporarily disabled and permanently disabled. Each status has its own benefits.

For temporary disabling, you will not need to restart VPS/Server for SELinux to change state. And after VPS/Server is restarted SELinux will automatically be enabled according to the operating system.

As for completely disabling you will have to restart the VPS/Server to permanently disable SELinux.

Depending on your purpose, you can see one of two cases.

Method 1: Disable SELinux Temporarily on CentOS 7

To disable SELinux temporarily on CentOS 7, w first need to SSH or access your VPS/server with root privileges. If you do not know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successful SSH, we use the commandsestatus to check the SELinux status:

disable SELinux on CentOS 7

As you can see in the picture above my current mode SELinux is enabled in . Then we use the setenforce 0 command to temporarily disable SELinux.

disable SELinux on CentOS 7

So we have successfully disabled SELinux temporarily. The advantage of this way is that there is no need to restart your VPS/Server.

Method 2: Disable SELinux Permanently on CentOS 7

To disable SELinux permanently on CentOS 7, we will need to change SELinux’s configuration file a bit.

Use the vi /etc/sysconfig/selinux command to edit the configuration file of SELinux.

Find the line SELINUX=enforcing select key i to enter the file editing state and set it to SELINUX=disabled .

disable SELinux on CentOS 7
Initial state.
disable SELinux on CentOS 7
Status after it has been edited.

Then press the key ESC to exit the edit state and use the key combination :x +Enter to save. Finally, you will need to use the command reboot to restart VPS/Server. Then check the SELinux status again with the following command:

AZDIGI Tutorial
sestatus
    

As a result, you will see that SELinux has been disabled on CentOS 7.

disable SELinux on CentOS 7

Summary

SELinux is a very good layer of security on CentOS 7. However, in some cases, we need to disable it and currently security on CentOS in general and Linux, in particular, is also very good, so disabling SELinux is almost not losing security too much.

So you know how to disable SELinux on CentOS 7.

If you find the article useful, don’t forget to rate 5 stars.

Wishing you success.

If you need assistance, you can contact support in the ways below:

Đánh giá

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign