关闭SELinux
关于SELinux(Security-EnhancedLinux) 的说明我们可以去百度搜索,SELinux默认的状态是Enforce状态,如果我们不关闭,在安装服务及很多操作的时候都会受影响。我们一般在实际使用中,都会关闭。用其它的方式来实现安全功能。本文以Centos 6.5为例
控制SELinux的位置在/etc/selinux/config目录
通过 cat /etc/selinux/config查看说明及当前设置的状态
[root@zdw ~]# cat /etc/selinux/config
# enforcing - SELinux security policy is enforced.//执行SELinux安全策略的执行。
# permissive - SELinux prints warnings instead of enforcing.//允许SELinux只打印警告而不是强制。
# disabled - No SELinux policy is loaded.//禁用SELinux策略不加载。
SELINUX=enforcing //当前的状态
通过getenforce或sestatus -v来查看状态,当前SELinux状态是enforcing开启的
[root@zdw ~]# getenforce
[root@zdw ~]# sestatus –v
临时关闭使用setenforce0,不用重启即可当前状态生效,但重启后还是Enforcing的状态
永久生效需要把/etc/selinux/config配置中的SELINUX=enforcing更改SELINUX=disable
方法一直接修改文件
进入vi/etc/selinux/config 更改SELINUX=disable
方法二用seq替换
替换sed -i s#SELINUX=enforcing#SELINUX=disabled#g /etc/selinux/config
通过grep查看 grep "disable" /etc/selinux/config
可以看到,SELINUX已经改为disabled
因为设置完成后,需要重启才能生效,但linux生产环境中一般不能重启,此时可以使用上面提到的setenforce 0来临时关闭SELINUX,这样也能正常使用,重启后,状态会变为disabled。
此时已经完成不重启,把SELINUX=disabled
本文出自 “赵东伟的学习记录” 博客,请务必保留此出处http://zhaodongwei.blog.51cto.com/4233742/1745837
原文:http://zhaodongwei.blog.51cto.com/4233742/1745837