查看 SELinux状态及关闭SELinux

SELinux 模式的切换

  1. enforcing:强制模式,代表 SELinux 运行中,且已经正确的开始限制 domain/type 了;
  2. permissive:宽容模式:代表 SELinux 运行中,不过仅会有警告信息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用;
  3. disabled:关闭,SELinux 并没有实际运行。

查看SELinux状态:

如果SELinux status参数为enabled即为开启状态
第一种:

[root@instance-0qymp8uo ~]# /usr/sbin/sestatus -v 
SELinux status:                 enabled

第二种:

[root@instance-0qymp8uo ~]# getenforce
Disabled

关闭SELinux

我们不想重启电脑又不想开启SELinux该怎么办呢?
【答案】将强制模式改为宽容模式!

第一种临时关闭(不用重启机器):

[root@instance-0qymp8uo ~]# setenforce 0 //设置SELinux 成为宽容(permissive)模式
[root@instance-0qymp8uo ~]# setenforce 1 //设置SELinux 成为强制(enforcing)模式

第二种修改配置文件(需要重启机器)
修改/etc/selinux/config/etc/sysconfig/selinux文件

将SELINUX=enforcing改为SELINUX=disabled

重启机器或服务器即可

原文地址:https://www.cnblogs.com/niuben/p/13299324.html