来一发Centos sed -i下令利用解说
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!明天在主动化安装剧本时必要防火墙设置文件开放3306端口sed-i
在含有特定字符串的行前拔出新行
sed-i/特定字符串/i新行字符串
例:
#vi/etc/sysconfig/iptables
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
#Firewallconfigurationwrittenbysystem-config-securitylevel
#Manualcustomizationofthisfileisnotrecommended.
*filter
:INPUTACCEPT
:FORWARDACCEPT
:OUTPUTACCEPT
:RH-Firewall-1-INPUT-
-AINPUT-jRH-Firewall-1-INPUT
-AFORWARD-jRH-Firewall-1-INPUT
-ARH-Firewall-1-INPUT-ilo-jACCEPT
#Uncommentlinebelowifyouhave2NICsandeth1ispublic
#-ARH-Firewall-1-INPUT-ieth0-jACCEPT
-ARH-Firewall-1-INPUT-picmp--icmp-typeany-jACCEPT
-ARH-Firewall-1-INPUT-p50-jACCEPT
-ARH-Firewall-1-INPUT-p51-jACCEPT
-ARH-Firewall-1-INPUT-pudp--dport5353-d224.0.0.251-jACCEPT
-ARH-Firewall-1-INPUT-pudp-mudp--dport631-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateESTABLISHED,RELATED-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport5060-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport4569-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport21-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport443-jACCEPT
#-ARH-Firewall-1-INPUT-mtcp-ptcp--dport3306-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport10000-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport10000:65000-jACCEPT
-ARH-Firewall-1-INPUT-jREJECT--reject-withicmp-host-prohibited
COMMIT
实行:
sed-i/-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT/i-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT/etc/sysconfig/iptables
#vi/etc/sysconfig/iptables
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
#Firewallconfigurationwrittenbysystem-config-securitylevel
#Manualcustomizationofthisfileisnotrecommended.
*filter
:INPUTACCEPT
:FORWARDACCEPT
:OUTPUTACCEPT
:RH-Firewall-1-INPUT-
-AINPUT-jRH-Firewall-1-INPUT
-AFORWARD-jRH-Firewall-1-INPUT
-ARH-Firewall-1-INPUT-ilo-jACCEPT
#Uncommentlinebelowifyouhave2NICsandeth1ispublic
#-ARH-Firewall-1-INPUT-ieth0-jACCEPT
-ARH-Firewall-1-INPUT-picmp--icmp-typeany-jACCEPT
-ARH-Firewall-1-INPUT-p50-jACCEPT
-ARH-Firewall-1-INPUT-p51-jACCEPT
-ARH-Firewall-1-INPUT-pudp--dport5353-d224.0.0.251-jACCEPT
-ARH-Firewall-1-INPUT-pudp-mudp--dport631-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateESTABLISHED,RELATED-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport5060-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport4569-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport21-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport443-jACCEPT
#-ARH-Firewall-1-INPUT-mtcp-ptcp--dport3306-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport10000-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport10000:65000-jACCEPT
-ARH-Firewall-1-INPUT-jREJECT--reject-withicmp-host-prohibited
COMMIT
欢迎大家来到仓酷云论坛! 选择交流平台,如QQ群,网站论坛等。 linux鸟哥的私房菜,第三版,基础篇,网上有pdf下的,看它的目录和每章的介绍就行了,这个绝对原创! 对于英语不是很好的读者红旗 Linux、中标Linux这些中文版本比较适合。现在一些Linux网站有一些Linux版本的免费下载,这里要说的是并不适合Linux初学者。 众所周知,目前windows操作系统是主流,在以后相当长的时间内不会有太大的改变,其方便友好的图形界面吸引了众多的用户。 我想即使Linux高手也很难快速准确精练的回答你。 为什么要学Linux呢?每个人都有不同的看法,下面我说说自己的感想吧。? 通过一条缓慢的调制解调器线路,它也能操纵几千公里以外的远程系统。
页:
[1]