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)相关的知识,希望对你有一定的参考价值。

参考文章:shell脚本中sed指令修改指定配置文件的内容

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指令 sed指令怎么选择列

linux 正则表达式,sed使用

bash 正则表达式初步--sed

Linux与bash:2.Linux终端命令之三剑客命令(grep,sed,awk)

python 全栈 linux基础 (部分)正则表达式 grep sed

shell 5-6合集