看进程运行在那个 port 上

Question

How to find out which application is using what port?

Answer

For AIX:

1. netstat -Aan | grep <port number>
- This shows if the specified <port number> is being used. The hex number in the first column is the address of protocol control block (PCB)

2. rmsock <addr of PCB> tcpcb
- This shows the process who is holding the socket. Note that this command must be run as root.

An AIX example:
# netstat -Aan | grep 9515
f100060003743b98 tcp4 0 0 *.9515 *.* LISTEN

# rmsock f100060003743b98 tcpcb
The socket 0x3743808 is being held by proccess 438488 (java).

For Windows:
Let’s say that we are looking for port 9549 — Data server.

Here is the command.

C:\> netstat -aon | findstr 9549

-a means list all active connections and their ports.
-o means include their process IDs.
-n means display the port numbers numerically.

The pipe symbol ( | ) means, that instead of the result of netstat being displayed on the screen, feed it’s result to the findstr process — we are looking specifically for the line which has port 9549.

You might see something like this
TCP 0.0.0.0:9549 0.0.0.0:0 LISTENING 3444

Now we know that process 3444 is using port 9549 (that last column right there, is the process ID).
You could now enter "tasklist".

C:\> tasklist | findstr 3444
java.exe 3444 Console 0 22,920 K

tasklist is another Windows command line utility which shows you a list of all active processes.

In this case, the process is the java process link to the data server process.
If you kill process 3444, you kill the data server service.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值