0.检测selinux是否开启,如开启则执行临时关闭和永久关闭

  1. [ `getenforce` != "Disabled" ] && setenforce 0 &> /dev/null && sed -i s/"^SELINUX=.*$"/"SELINUX=disabled"/g /etc/selinux/config

1.查看selinux状态:

[root@wyf ~]# getenforce 
[root@wyf ~]# sestatus

2.临时关闭selinux:

[root@wyf ~]# setenforce 0

3.永久关闭selinux:

修改配置文件/etc/selinux/config,将其中SELINUX设置为disabled

[root@wyf ~]# vim /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 - No SELinux policy is loaded.  
#SELINUX=enforcing  
SELINUX=disabled  #将SELINUX=enforcing改为SELINUX=disabled
# SELINUXTYPE= can take one of three two values:  
#     targeted - Targeted processes are protected,  
#     minimum - Modification of targeted policy. Only selected processes are protected.   
#     mls - Multi Level Security protection.  
SELINUXTYPE=targeted

设置后需要重启才能生效。