linux配置端口和查看日志


進程端口篇

查看進程:

ps -ef

查看對應的進程

ps -ef|grep tomcat

31450 為進程號

 

查看端口占用:

netstat -lnp|grep  8080

31450 就是剛剛查詢tomcat的進程號

 

查看進程信息

ps 31450

 

 終止進程:

kill -9 31450 

 

防火牆添加端口

如果防火牆在開啟狀態查看端口:

service iptables status

其中22和8080 是防火牆中開啟的端口

 

 

如果防火牆在關閉狀態查看端口

root權限 輸入:vi /etc/sysconfig/iptables

查看里面添加了什么端口,  我們也可以通過在這里添加我們需要的端口

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080-j ACCEPT       (根據你們需要改寫端口號)

 保存后重啟防火牆:

/etc/init.d/iptables restart  #重啟防火牆使配置生效 

--------------------

1 關閉防火牆-----service iptables stop 
2 啟動防火牆-----service iptables start 
3 重啟防火牆-----service iptables restart 
4 查看防火牆狀態--service iptables status 
5 永久關閉防火牆--chkconfig iptables off 
6 永久關閉后啟用--chkconfig iptables on

重啟服務器

立即重啟

shutdown -r now

立即關機

shutdown -h now

取消前一個關機命令

shutdown  -c

 

日志篇

 


免責聲明!

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



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