通过配置文件调整SELinux的参数:
[root@www ~]# vi /etc/selinux/config
SELINUX=enforcing <==调整 enforcing|disabled|permissive
SELINUXTYPE=targeted <==目前仅有 targeted 与 strict
SELinux 的启动与关闭 【重要常识】:
改变了政策则需要重新开机。
SELinux 是整合到核心里面去的, 只可以在 SELinux 运作下切换成为强制 (enforcing) 或宽容 (permissive) 模式,不能够直接关闭 SELinux 的!
由 SELinux 关闭 (disable) 的状态到开启的状态也需要重新开机。
SELinux有三种运作模式:
Enforcing:强制模式
Permissive:宽容模式
Disabled:关闭
将 SELinux 在 Enforcing 与 permissive 之间切换与查看
[root@www ~]# setenforce 0
[root@www ~]# getenforce Permissive
[root@www ~]# setenforce 1
[root@www ~]# getenforce Enforcing
如果要恢复运行SELinux则可以运行
# setenforce
1
这条命令会把SELinux设定成Enforcing模式
2.把SELinux永久设定为Permissive模式
这里需要讲一下Permissive和Enforcing模式的区别。
SELinux有三种模式:Enforcing, Permissive and Disable.
Enforcing模式就是应用SELinux所设定的Policy,
所有违反Policy的规则(Rules)都会被SELinux拒绝
Permissive和Enforcing的区别就在于它还是会遵循SELinux的Policy,但是对于违反规则的操作只会予以记录而并不会拒绝操作
Disable 顾名思义就是完全禁用SELinux
如果要永久设定为Permissive模式,我们就要修改SELinux的配置文件
/etc/sysconfig/selinux (在RHEL5下这是一个symbolic link to /etc/selinux/conf)
# 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 - SELinux is fully disabled.
SELINUX=enforcing
#
SELINUXTYPE= type of policy in use. Possible values are:
# targeted -
Only targeted network daemons are protected.
# strict -
Full SELinux protection.
SELINUXTYPE=targeted
修改SELINUX=permissive,然后重新启动就可以了