《在各種系統(tǒng)上查詢端口號被哪個(gè)進(jìn)程占用的方法》要點(diǎn):
本文介紹了在各種系統(tǒng)上查詢端口號被哪個(gè)進(jìn)程占用的方法,希望對您有用。如果有疑問,可以聯(lián)系我們。
匯總了一下各種平臺(tái)下查詢端口被哪個(gè)程序占用的方法,可以在安裝失敗,分析異常端口等時(shí)候使用.
一、Windows平臺(tái)
查詢端口1793是誰在使用,首先找到進(jìn)程id.
PS C:\Users\d00101270> netstat -aon | findstr “1793”
TCP 10.70.103.84:1793 72.14.213.113:443 SYN_SENT 792
上面最后一列是進(jìn)程id,?我們使用tasklist來查找進(jìn)程id對應(yīng)的進(jìn)程名
PS C:\Users\d00101270> tasklist | findstr “792”
GoogleUpdate.exe 792 Console 1 8,220 K
二、Linux
第一種方案:
$netstat -pan | grep 19916
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 10.71.173.225:19916 0.0.0.0:* LISTEN?28517/DiameterAdpt
第二種方案:
$lsof -i:23
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
telnet 10582 d101270 3u IPv4 263403399 TCP linux227.huawei:61172->10.71.173.225:telnet (ESTABLISHED)
三、AIX
$netstat -Aan|grep 30542
f10000f303321b58 tcp4 0 0 *.30542 *.* LISTEN
$rmsock f10000f303321b58 tcpcb
The socket 0x3321800 is being held by proccess 692476 (db2sysc).
四、HP-UX
使用lsof?-i 可以查到程序名,進(jìn)程號,?如果查9090端口
#lsof -i|grep 9090
java?29607?sync?30u?IPv4 0x12b6ce380?0t0?TCP *:9090 (LISTEN)
java?29607?sync?35u?IPv4 0x122c194c0?0t1343?TCP zy:9090->10.17.109.110:1206 (ESTABLISHED)
java?29607?sync?36u?IPv4?0xca46d9c0?0t2680?TCP zy:9090->172.16.4.109:1105 (ESTABLISHED)
java?29607?sync?37u?IPv4 0x126e140c0?0t2796?TCP zy:9090->172.16.4.111:1094 (ESTABLISHED)
java?29607?sync?38u?IPv4 0x105c25b80?0t2409?TCP zy:9090->172.16.4.122:1576 (ESTABLISHED)
java?29607?sync?39u?IPv4 0x106bc4040?0t500?TCP zy:9090->10.17.77.96:1300 (ESTABLISHED)
java?29607?sync?41u?IPv4?0xca2a1dc0?0t443?TCP zy:9090->132.97.238.187:1642 (ESTABLISHED)
java?29607?sync?42u?IPv4 0x12245f200?0t2443?TCP zy:9090->132.97.191.143:2928 (ESTABLISHED)
java?29607?sync?47u?IPv4 0x122c19dc0?0t2347?TCP zy:9090->10.17.109.110:1207 (ESTABLISHED)
#ps -ef|grep 29607
sync 29607?1?0?May 19???163:02 /opt/java1.4/bin/PA_RISC2.0/java -server -Xms128m -Xmx512m -Dja
root 17445 16305?1 17:31:19 pts/to?0:00 grep 29607
五、SUN Solaris
第一種方案:
1.?使用下面shell script,先建立一個(gè)port.sh文件:
# more /tmp/port.sh
#!/bin/sh
for pid in `ls /proc`
do
pf=`/usr/bin/pfiles $pid 2>/dev/null`
if echo $pf | grep $1 > /dev/null 2>&1
then
echo $pid
/usr/bin/pargs $pid
fi
done
2.?運(yùn)行port.sh, 傳入端口號,比如53250 :
#?/tmp/port.sh 53250
3.?運(yùn)行結(jié)果如下:
1225
1225:?/usr/lib/thunderbird/thunderbird-bin -UILocale zh-CN
-contentLocale CN
argv[0]: /usr/lib/thunderbird/thunderbird-bin
argv[1]: -UILocale
argv[2]: zh-CN
argv[3]: -contentLocale
argv[4]: CN
4212
4212:?/bin/sh /tmp/port.sh 53250
argv[0]: /bin/sh
argv[1]: /tmp/port.sh
argv[2]: 53250
第二種方案:
下載lsof軟件,?使用lsof軟件可以實(shí)現(xiàn),同Linux.
第三種方案:
使用MDB
from socket info (netstat output), you can know its vnode
from vnode info, you can know which process owns it
from process info, you can know its args, so comes the result.
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/4691.html