how to check which process occupied the port

来源:互联网 发布:淘宝怎么买电话轰炸 编辑:程序博客网 时间:2024/04/30 21:06

从网上找来的,灰常好用:

1. netstat -Aan|grep <portnumber>

找到该端口连接对应的PCB/ADDR和连接的协议类型。

注:PCB ----Protocol Control Block
2. 如果是tcp连接,则rmsock <PCB/ADDR> tcpcb

如果是udp连接,则rmsock <PCB/ADDR> inpcb


下面我们以telnet服务所使用的23号端口为例,说明该方法:
#netstat -Aan|grep 23

f1000200019ce398 tcp 0 0 *.23 *.* LISTEN


可以看到PCB/ADDR为f1000200019ce398,且协议类型为tcp。
#rmsock f1000200019ce398 tcpcb

The socket 0x19ce008 is being held by proccess 185006 (inetd).


命令报告该端口正在被inetd进程使用,PID为185006。
注意:rmsock命令需要root权限执行
0 0
原创粉丝点击