发表时间:2009-01-29
最后修改:2009-01-29
几个非常强大的命令,我认为作为一名程序员一定要懂这几个命令:
1.netstat -a 列出所有正在运行程序的端口 如下:
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:90 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1110 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING
TCP 0.0.0.0:8009 0.0.0.0:0 LISTENING
TCP 0.0.0.0:19780 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1052 127.0.0.1:1110 ESTABLISHED
TCP 127.0.0.1:1110 127.0.0.1:1052 ESTABLISHED
TCP 127.0.0.1:1141 127.0.0.1:1433 ESTABLISHED
TCP 127.0.0.1:1143 127.0.0.1:1433 ESTABLISHED
2.netstat -ano 列出所有正在运行程序的端口及PID 如下:
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:90 0.0.0.0:0 LISTENING 3468
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1120
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:1110 0.0.0.0:0 LISTENING 1680
TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 2880
TCP 0.0.0.0:8009 0.0.0.0:0 LISTENING 3468
TCP 0.0.0.0:19780 0.0.0.0:0 LISTENING 1680
TCP 127.0.0.1:1052 127.0.0.1:1110 ESTABLISHED 3368
TCP 127.0.0.1:1110 127.0.0.1:1052 ESTABLISHED 1680
TCP 127.0.0.1:1141 127.0.0.1:1433 ESTABLISHED 3468
TCP 127.0.0.1:1143 127.0.0.1:1433 ESTABLISHED 3468
TCP 127.0.0.1:1433 127.0.0.1:1141 ESTABLISHED 2880
TCP 127.0.0.1:1433 127.0.0.1:1143 ESTABLISHED 2880
TCP 127.0.0.1:8005 0.0.0.0:0 LISTENING 3468
UDP 0.0.0.0:445 *:* 4
3.netstat -anb 列出所有正在运行程序的端口,PID及使用这个端口的进程( ):
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:90 0.0.0.0:0 LISTENING 3468
[java.exe]
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1120
c:\windows\system32\WS2_32.dll
C:\WINDOWS\system32\RPCRT4.dll
c:\windows\system32\rpcss.dll
C:\WINDOWS\system32\svchost.exe
C:\WINDOWS\system32\ADVAPI32.dll
[svchost.exe]
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
[System]
TCP 0.0.0.0:1110 0.0.0.0:0 LISTENING 1680
[avp.exe]
TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 2880
[sqlservr.exe]
TCP 0.0.0.0:8009 0.0.0.0:0 LISTENING 3468
[java.exe]
TCP 0.0.0.0:19780 0.0.0.0:0 LISTENING 1680
[avp.exe]
TCP 127.0.0.1:8005 0.0.0.0:0 LISTENING 3468
[java.exe]
TCP 192.168.1.111:139 0.0.0.0:0 LISTENING 4
[System]
TCP 127.0.0.1:1052 127.0.0.1:1110 ESTABLISHED 3368
[MsnMsgr.Exe]
TCP 127.0.0.1:1110 127.0.0.1:1052 ESTABLISHED 1680
[avp.exe]
TCP 127.0.0.1:1141 127.0.0.1:1433 ESTABLISHED 3468
[java.exe]
TCP 127.0.0.1:1143 127.0.0.1:1433 ESTABLISHED 3468
[java.exe]
TCP 127.0.0.1:1433 127.0.0.1:1143 ESTABLISHED 2880
[sqlservr.exe]
TCP 127.0.0.1:1433 127.0.0.1:1141 ESTABLISHED 2880
[sqlservr.exe]
TCP 192.168.1.111:1054 207.46.109.34:1863 ESTABLISHED 1680
[avp.exe]
TCP 192.168.1.111:2741 192.168.1.103:139 FIN_WAIT_2 4
[System]
UDP 0.0.0.0:1434 *:* 2880
[sqlservr.exe]
-------------------------------------------------------------------------------------------
注:也可直接开始运行 cmd /c netstat -anb
如果你的系统没有netstat 这个命令那可能是你的系统PATH配置有误:
PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;