SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统。在这种访问控制体系的限制下,进程只能访问那些在他的任务中所需要文件。SELinux 默认安装在 Fedora 和 Red Hat Enterprise Linux 上。
虽然SELinux很好用,但是在多数情况我们还是将其关闭,因为在不了解其机制的情况下使用SELinux会导致软件安装或者应用部署失败。
查看SELINUX的状态
/usr/sbin/sestatus -v
SELinux status: enabled 开启状态
SELinux status: disabled 关闭状态
改变SELINUX的状态
- 临时关闭(立即生效,重启失效)
setenforce 0 # 设置selinux为permissive模式(即关闭)
setenforce 1 # 设置selinux为enforcing模式(即开启) - 永久关闭
修改配置文件 /etc/selinux/config
selinux=disabled
配置文件内容
# 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 three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted