Linux关闭SELinux的方法

您所在的位置:网站首页 查看selinux状态 Linux关闭SELinux的方法

Linux关闭SELinux的方法

2023-09-04 06:09| 来源: 网络整理| 查看: 265

SELinux一共有3种状态,分别是Enforcing,Permissive和Disabled状态。

Enforcing:强制模式。代表SELinux在运行中,且已经开始限制domain/type之间的验证关系

Permissive:宽容模式。代表SELinux在运行中,不过不会限制domain/type之间的验证关系,即使验证不正确,进程仍可以对文件进行操作。不过如果验证不正确会发出警告

Disabled:关闭模式。SELinux并没有实际运行

可以通过setenforce命令来设置前面两种状态,而如果想修改为disable状态,需要修改配置文件,同时重启系统。

Enforcing状态的值是1,permissive状态是0,因此设置为permissive,命令就是:setenforce 0|1

临时关闭SELinux:setenforce 0

临时开启SELinux:setenforce 1

查看当前状态命令:getenforce

1 [root@localhost ~]# setenforce 0 2 [root@localhost ~]# getenforce 3 Permissive

永久关闭SELinux需修改配置文件:cat /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 命令临时打开了



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3