RHEL/CentOS 关闭 Selinux

好风 发表于 2016-11-16T07:44:45.942876Z
引用地址:https://plus.ooclab.com/note/article/1295

基本操作

查看当前 selinux 状态:

# sestatus 
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

禁用 selinux

通常 RHEL/CentOS 的 Selinux 配置文件在 /etc/sysconfig/selinux :

# 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=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

修改 SELINUX=disabled , 重启系统即可。

如果不希望重启系统,可以临时禁用 selinux :

# setenforce 0

或者 (CentOS7) :

echo 0 > /sys/fs/selinux/enforce