想要批量修改Linux 的一些配置文件
对sed不是太熟悉,找到了这个比较笨的方法,修改HOSTNAME成功了
可是修改SELINUX的配置文件确出了问题- #sed -i '/HOSTNAME/d' /etc/sysconfig/network
- #echo 'HOSTNAME=testname' >> /etc/sysconfig/network
-
- #sed -i '/SELINUX/d' "/etc/selinux/config"
- #echo 'SELINUX=disablexxx' >> "/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 these two values:
- # targeted - Targeted processes are protected,
- # mls - Multi Level Security protection.
- SELINUXTYPE=targeted
复制代码
- # This file controls the state of SELinux on the system.
- # enforcing - SELinux security policy is enforced.
- # permissive - SELinux prints warnings instead of enforcing.
- # disabled - No SELinux policy is loaded.
- # targeted - Targeted processes are protected,
- # mls - Multi Level Security protection.
-
-
- SELINUX=disablexxx
复制代码 修改完了,成了这样,后面的内容都被删除了。
正确的使用sed修改某个参数的方法是什么? |