linux bash sed指令 sed命令(正则表达式替换)替换/etc/selinux/config参数(SELINUX=enforcing -->SELINUX=permissive)
Posted Dontla
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux bash sed指令 sed命令(正则表达式替换)替换/etc/selinux/config参数(SELINUX=enforcing -->SELINUX=permissive)相关的知识,希望对你有一定的参考价值。
centos7:
/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
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
我们需要将里面SELINUX=enforcing
改成SELINUX=permissive
只需运行脚本:
#!/bin/bash
SELINUX_CONF=/etc/selinux/config
cp /etc/selinux/config /etc/selinux/config.bak
sed -i -e "s:SELINUX=.*:SELINUX=permissive:g" $SELINUX_CONF
echo "test success!"
以上是关于linux bash sed指令 sed命令(正则表达式替换)替换/etc/selinux/config参数(SELINUX=enforcing -->SELINUX=permissive)的主要内容,如果未能解决你的问题,请参考以下文章
Linux与bash:2.Linux终端命令之三剑客命令(grep,sed,awk)