SELinux(Security-Enhanced Linux)是美国国家安全局(NSA)对于强制访问控制的实现,是Linux历史上最杰出的新安全子系统。NSA是在Linux社区的帮助下开发了一种访问控制体系,在这种访问控制体系的限制下,进程只能访问那些在他的任务中所需要文件。SELinux默认安装在Fedora和Red Hat Enterprise Linux上,也可以作为其他发行版上容易安装的包得到。
一、查看SELinux状态
查看SELinux状态:getenforce命令。SELinux一共有3种状态,分别是Enforcing,Permissive和Disabled状态。第一种Enforcing是默认状态,表示强制启用,第二种Permissive是宽容的意思,即大部分规则都放行。第三种Disabled是禁用,即不设置任何规则。
二、关闭SELinux方法
临时关闭:只能通过setenforce命令来设置前面两种状态,而如果想修改为disable状态,需要修改配置文件,同时重启系统。我们先看修改,Enforcing状态的值是1,permissive状态是0,因此设置为permissive,命令就是:setenforce 0
[root@fedora ~]# setenforce 0 [root@fedora ~]# getenforce Permissive
永久关闭:修改/etc/selinux/config文件,然后重启reboot
[root@fedora selinux]# cat config # 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 three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted