/etc/selinux/config模式修改


[root@test ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
1、状态解释
enforcing:强制模式,策略被完整执行,SELinux的主要模式,SELinux 运作中且已经正确的开始限制 domain/type
permissive:宽容模式:SELinux 运作中,策略规则不被强制执行,相反,只是审核遭受拒绝的消息,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用
disabled:SELinux内核机制是完全关闭的。

2、查看selinux状态
[root@test ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
[root@test ~]#

3、临时关闭
setenforce 0

4、临时打开 permissive转enforcing
setenforce 1

5、永久改变,需重新开机,整合到内核模块
cp -a /etc/selinux/config /etc/selinux/config.bak
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
或者 sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
/SELINUX/为包含匹配以//内字符的行
s 替换命令
sed -i 直接修改源文件,没有-i只是把修改输出到标准输出,不修改源文件
s/要查找的字符串/修改后的字符串/
整个命令需要用单引号引起来
最后是要修改的文件名


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM