关闭SElinux

# 安装工具包
sudo apt install selinux-utils -y

SELinux一共有3种状态

  • Enforcing:强制模式。代表SELinux在运行中,且已经开始限制domain/type之间的验证关系
  • Permissive:宽容模式。代表SELinux在运行中,不过不会限制domain/type之间的验证关系,即使验证不正确,进程仍可以对文件进行操作。不过如果验证不正确会发出警告
  • Disabled:关闭模式。SELinux并没有实际运行

! 临时关闭SElinux

# 临时关闭SELinux:
setenforce 0

# 临时开启SELinux:
setenforce 1

# 查看当前状态命令:
getenforce

! 永久关闭SELinux

需修改配置文件:/etc/selinux/config,修改 SELINUX=disabled。

 1 [root@localhost ~]# cat /etc/selinux/config 
 2 
 3 # This file controls the state of SELinux on the system.
 4 # SELINUX= can take one of these three values:
 5 #     enforcing - SELinux security policy is enforced.
 6 #     permissive - SELinux prints warnings instead of enforcing.
 7 #     disabled - No SELinux policy is loaded.
 8 SELINUX=disabled      #修改为disabled
 9 # SELINUXTYPE= can take one of three two values:
10 #     targeted - Targeted processes are protected,
11 #     minimum - Modification of targeted policy. Only selected processes are protected. 
12 #     mls - Multi Level Security protection.
13 SELINUXTYPE=targeted 

<<< 注意:修改SELinux永久关闭,必须重启服务器,才能生效。 <<<

永久关闭后,不能通过 setenforce 1 命令临时打开了

评论