1.查看linux系统selinux状态
[root@iZbp121075lo3b6ujbxbcvZ ~]# sestatus -v
SELinux status: disabled
开启:endabled
关闭:disabled
2.临时关闭selinux,实时生效,系统重启后失效。
setenforce 0 立刻关闭 SELINUX #设置SELinux 成为permissive模式
setenforce 1 立刻启用 SELINUX #设置SELinux 成为enforcing模式
3.永久关闭selinux,并且使其实时生效
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config #一键关闭selinux
setenforce 0 #使其实时生效
当然也可以修改修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled,重启后依然生效。
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 three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
上面的文件是selinux配置文件,该配置提供有三各选型,enforcing,disabled,enabled,分别说明如下:enforcing:强制模式,代表 SELinux 运作中,且已经正确的开始限制 domain/type 了;
permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用;
disabled:关闭,SELinux 并没有实际运作。
selinux到底是什么?
Security Enhanced Linux(SELinux)是一种针对Linux®系统的安全体系结构,它允许管理员更好地控制谁可以访问系统。它最初由美国国家安全局(NSA)开发,作为Linux内核的一系列补丁,使用Linux安全模块(LSM)。SELinux于2000年发布到开源社区,并于2003年集成到上游Linux内核中。