SELinux 宽容模式(permissive) 强制模式(enforcing) 关闭(disabled)

SELinux 宽容模式(permissive) 强制模式(enforcing) 关闭(disabled)

SElinux共有3中状态。
1、selinux的配置文件:/etc/selinux/config

This file controls the state of SELinux on the system.

3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=permissive
8 # SELINUXTYPE= can take one of three two values:
9 # targeted - Targeted processes are protected,
10 # minimum - Modification of targeted policy. Only selected processes are protected.
11 # mls - Multi Level Security protection.
12 SELINUXTYPE=targeted

enforcing:强制模式,代表 SELinux 运作中,且已经正确的开始限制 domain/type 了;
permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用;
disabled:关闭,SELinux 并没有实际运作。
2、查看现在selinux的状态:
sestatus
3、永久改变selinux的状态,需要重新开机,因为,selinux是整合到内核的模块。
4、临时关闭selinux:setenforce 0
5、临时打开,由permissive转enforcing:setenforce 1
6、使用sed命令修改selinux的配置文件:
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
解说:/SELINUX/为包含匹配以//内字符的行
s为替换命令
sed -i 表示直接修改源文件,没有-i只是把修改输出到标准输出,并不修改源文件。
s/要查找的字符串/改后的字符串/
注意,整个命令要用单引号引起来。
最后跟上文件名

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值