Windows下查看某端口号被哪个进程占用

 
 
  

整理自网络,备查。

首先查看端口号被哪个进程占用,用netstat -ano即可查出,不过-o只能显示进程的pid

以端口号1521为例:

C:\Documents and Settings\Administrator>netstat -ano | find "1521"
  TCP    0.0.0.0:1521           0.0.0.0:0              LISTENING       212
  TCP    10.0.5.215:1049        10.0.5.215:1521        ESTABLISHED     276
  TCP    10.0.5.215:1050        10.0.5.215:1521        ESTABLISHED     372
  TCP    10.0.5.215:1051        10.0.5.215:1521        ESTABLISHED     400
  TCP    10.0.5.215:1052        10.0.5.215:1521        ESTABLISHED     388
  TCP    10.0.5.215:1521        10.0.5.215:1049        ESTABLISHED     212
  TCP    10.0.5.215:1521        10.0.5.215:1050        ESTABLISHED     212
  TCP    10.0.5.215:1521        10.0.5.215:1051        ESTABLISHED     212
  TCP    10.0.5.215:1521        10.0.5.215:1052        ESTABLISHED     212

再查看276、372、400、388对应的进程详细信息

C:\Documents and Settings\Administrator>tasklist | findstr "212"
TNSLSNR.EXE                    212 Console                    0      6,704 K

C:\Documents and Settings\Administrator>tasklist | findstr "276"
jqs.exe                       1276 Console                    0      1,812 K
oracle.exe                     276 Console                    0    156,192 K
oscar.exe                     5876 Console                    0    105,276 K

C:\Documents and Settings\Administrator>tasklist | findstr "372"
oracle.exe                     372 Console                    0    118,856 K
java.exe                      4696 Console                    0     91,372 K

C:\Documents and Settings\Administrator>tasklist | findstr "388"
msdtc.exe                      660 Console                    0      4,388 K
oracle.exe                     388 Console                    0    118,180 K
alg.exe                       3884 Console                    0      2,948 K


同样,查看某个进程占用哪些端口号,也可以使用上述方法。

获取进程的pid

C:\Documents and Settings\Administrator>netstat -ano | find "276"
  TCP    0.0.0.0:1047           0.0.0.0:0              LISTENING       276
  TCP    10.0.5.215:1049        10.0.5.215:1521        ESTABLISHED     276
  TCP    127.0.0.1:5152         0.0.0.0:0              LISTENING       1276

也可以通过任务管理器,选择查看->选择列->PID选项查看程序的pid

查看对应pid进程占用的端口号

C:\Documents and Settings\Administrator>netstat -ano | find "276"
  TCP    0.0.0.0:1047           0.0.0.0:0              LISTENING       276
  TCP    10.0.5.215:1049        10.0.5.215:1521        ESTABLISHED     276
  TCP    127.0.0.1:5152         0.0.0.0:0              LISTENING       1276


 

 
 

你可能感兴趣的:(linux)