论/etc/selinux/conf和/etc/sysconfig/selinux之间的区别
一、SELinux
SELinux 是 Linux 内核中提供的强制访问控制系统。SELinux 有 disabled、permissive、enforcing 三种选择。
- disabled: 不启用控制系统
- permissive:开启控制系统,但是出于警告模式。即使你违反了策略的话,它让你继续操作,但是把你的违反的内容记录下来。
- Enforcing:开启控制系统,出于强制状态。一旦违反了策略,就无法继续操作哦下去。
[root@web ~]# cat /etc/selinux/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 - 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
二、/etc/selinux/config 与 /etc/sysconfig/selinux 区别
其实,/etc/sysconfig/selinux 是 /etc/selinux/config 的一个软链接(soft link),/etc/selinux/config 才是源文件。
但是,修改 /etc/sysconfig/selinux 会导致软链接的关系破裂,变成普通文件且不再被系统作为selinux的配置文件。
[root@web ~]# ls /etc/sysconfig/selinux -l lrwxrwxrwx 1 root root 17 Aug 8 2016 /etc/sysconfig/selinux -> ../selinux/config
三、设置 SELinux 的方法
1、永久方法 (需要重启服务器)
执行命令 vi /etc/selinux/config 修改文件中设置 SELINUX=disabled ,然后重启服务器。
或者执行一条替换命令:
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
2、临时方法(设置系统参数)
使用 setenforce 命令来切换 enforcing 与 permissive 模式,不需要重启。
- setenforce 0 permissive模式
- setenforce 1 enforcing模式
查看SELinux的状态:
[root@web ~]# getenforce
Enforcing
浙公网安备 33010602011771号