unix linux

关注公众号 jb51net

关闭
首页 > 操作系统 > unix linux > linux 查看端口占用

Linux/window下怎样查看某个端口被哪个程序/进程占用

作者:

Linux/window下怎样查看某个端口被哪个程序/进程占用,接下来详细介绍如何查看占用端口的程序,有需要的朋友可以参考下
Windows:
C:/Users/ewanbao>netstat -aon|findstr "123"
TCP 127.0.0.1:55123 0.0.0.0:0 LISTENING 5092
TCP 127.0.0.1:55123 127.0.0.1:55124 ESTABLISHED 5092
TCP 127.0.0.1:55124 127.0.0.1:55123 ESTABLISHED 5092
UDP 0.0.0.0:123 *:* 1416
UDP [::]:123 *:* 1416
[注]:执行netstat -aon|findstr "123"以后,就可以看到5092进程中TCP打开123端口,1416进程打开UDP123端口

C:/Users/ewanbao>tasklist|findstr "1416"
svchost.exe 1416 Services 0 13,540 K
[注]:执行tasklist|findstr "1416"后就可以看到是svchost.exe在UDP打开123端口
Linux:
cba001:~ # lsof -i:5300
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
named 26751 root 20u IPv4 64750499 TCP localhost:hacl-hb (LISTEN)
named 26751 root 21u IPv4 64750501 TCP cba001.eapac:hacl-hb (LISTEN)
named 26751 root 22u IPv4 64750503 TCP 192.168.0.10:hacl-hb (LISTEN)
named 26751 root 512u IPv4 64750498 UDP localhost:hacl-hb
named 26751 root 513u IPv4 64750500 UDP cba001.eapac:hacl-hb
named 26751 root 514u IPv4 64750502 UDP 192.168.0.10:hacl-hb
[注]:执行lsof -i:5300以后就可以看到26751进程在TCP和UDP上都打开了5300端口.
cba001:~ # ps -ef|grep 26751
root 10118 26915 0 12:59 pts/8 00:00:00 grep 26751
root 26751 1 0 Jul06 ? 00:02:06 /opt/ipworks/IPWdns/usr/bin/named
[注]:执行ps -ef|grep 26751以后就可以看到是named进程打开了5300端口

查看进程ID
lsof -w -n -i tcp:8080
fuser -n tcp 8080netstat -anp|grep :8080[[:blank:]]
杀掉占用端口的进程PID:
kill -9 pidnumber
您可能感兴趣的文章:
阅读全文