Linux Shell腳本_關閉防火牆


轉至:https://blog.csdn.net/weixin_40816738/article/details/105244851

① 腳本編寫
創建腳本

vim closeFirewall.sh

添加腳本內容如下:

if egrep "7.[0-9]" /etc/redhat-release &>/dev/null;then

  systemctl stop firewalld

   systemctl disable firewalld

elif

  egrep "6.[0-9]" /etc/redhat-release &>/dev/null; then

   service iptables stop

   chkconfig iptables off

fi

保存退出:wq

 

② 運行腳本

chmod u+x closeFirewall.sh

./closeFirewall.sh

或者

bash closeFirewall.sh

 

③ 腳本內容簡述

這是一個centos7和centos6 2個版本防火牆腳本
先去查看/etc/redhat-release文件中的系統版本內容,然后用正則表達式區配7.x還是6.x,然后使用管道命令過濾,最后,針對不同系統走不同分支

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM