识别占用端口的程序

由于工作的关系,经常要确认应用软件是否运行正常,查看监听端口的程序是否是期望的程序。通过google搜了一些常用的方法,https://www-304.ibm.com/support/docview.wss?uid=swg21264632,这篇文章挺好,unxi\win\linux全搞了。

要点记录下来,方便以后用。

unix:

1.netstat -Aan | grep <port number>

ex:

f1000e00022a23b0 tcp        0      0  *.9080             *.*                LISTEN

2.rmsock <addr of PCB> tcpcb

ex:

rmsock f1000e00022a23b0 tcpcb

 

The socket 0x22a2008 is being held by proccess 16449770 (java).

3.ps -ef|grep 16449770

window:

 1.netstat -aon | findstr "<port number>"

 TCP    0.0.0.0:912            0.0.0.0:0              LISTENING       3568

这就是 pid --3568,进程管理器查一下就ok了

 

linux:

1. netstat -anp | grep <port number>

直接就出pid。

    2.fuser -n tcp <port number>

能看到其他相关信息。

 

--上面的方法貌似不靠谱;必须用root用户

netstat -tnlp|grep <port number> 能出pid

你可能感兴趣的:(linux,unix,socket,IBM,Google)