SELINUX_STATE=$(getenforce)
if [ "$SELINUX_STATE" == "Enforcing" ]; then
echo "SELinux is enabled"
elif [ "$SELINUX_STATE" == "Permissive" ]; then
echo "SELinux is permissive"
else
echo "SELinux is disabled (or missing)"
fi
ENABLED=`cat /selinux/enforce`
if [ "$ENABLED" == 1 ]; then
echo "SELinux is enabled, disable? (yes/no):"
read disable
if [ $disable == "yes" ]; then
echo "disabling selinux"
setenforce 0
fi
fi
2条答案
按热度按时间dbf7pr2w1#
更正已接受的答案。
a)按如下所示使用“getenforce”来编写脚本
B)
setenforce 0
将selinux设置为permissive模式-这与disabled不同。禁用的唯一方法是编辑配置并重新启动。rnmwe5a22#
此脚本应作为root用户运行,或具有执行以下操作的权限: