centos7.9系统禁用selinux脚本
临时关闭(无需重启,重启后恢复)
setenforce permissive
永久关闭(需要重启)
配置文件路径 /etc/sysconfig/selinux
修改配置项 SELINUX=enforcing 为 SELINUX=disabled
sed -i 's/SELINUX=enforcing/'SELINUX=disabled'/g' /etc/sysconfig/selinux
自动化脚本(临时关闭+永久关闭)
#!/bin/bash
result=$(sestatus|grep "^Current mode:\s*enforcing")
echo $result
if [[ "$result" != "" ]];then
echo "正在临时关闭selinux..."
setenforce permissive
fi
result=$(sestatus|grep "^SELinux status:\s*enabled")
echo $result
if [[ "$result" != "" ]];then
echo "正在禁用selinux..."
sed -i 's/SELINUX=enforcing/'SELINUX=disabled'/g' /etc/sysconfig/selinux
fi

浙公网安备 33010602011771号