1. 程式人生 > >linux命令總結四(iptables/firewalld/rc.local/systemctl)

linux命令總結四(iptables/firewalld/rc.local/systemctl)

linux找不到iptables

//關閉防火牆,安裝或更新服務,開啟iptables
systemctl stop firewalld
yum install iptables-services
systemctl enable iptables
systemctl start iptables

service iptables save

有時候linux版本不同,iptables不可用,只能用firewalld替代
防火牆是整個資料包進入主機前的第一道關卡。Iptables和firewalld只能開一個。 需要先遮蔽一個

//停止並遮蔽iptables:
systemctl stop iptables
systemctl mask
iptables //安裝、解除遮蔽並啟動firewalld yum install firewalld systemctl unmask firewalld systemctl start firewalld systemctl status firewalld //設定開機啟動 systemctl enable firewalld

設定開機啟動

通過修改/etc/rc.local檔案可以設定activemq開機啟動

cd /usr/server/backup/activemq/bin/ && ./activemq start

如果安裝在非root賬戶下,加上

sudo changhf -c '/usr/server/backup/activemq/bin/activemq start'

設定之前先驗證下修改該檔案是否生效

systemctl list-dependencies multi-user.target | grep rc-local
//執行上面命令如果沒有輸出結果,執行如下命令後再次測試
chmod +x /etc/rc.d/rc.local
systemctl daemon-reload

systemctl

systemctl實際上是將service 和 chkconfig兩個命令組合在一起

systemctl enable firewalld.service  //設定開機啟動防火牆
systemctl disable firewalld.service //設定開機不啟動防火牆
//常用操作
systemctl start|stop|restart|status|enable|disable firewalld.service