查看端口占用情况,以及占用端口的程序

windows查看端口占用
在windows命令行窗口下执行:
netstat -aon|findstr "8080"

TCP 127.0.0.1:80 0.0.0.0:0 LISTENING 2448
端口“8080”被PID(进程号)为2448的进程占用。
查看端口“8080”被哪个应用占用,,继续执行下面命令:
tasklist|findstr "2448"
notepad.exe 2016 Console 0 16,064 K

linux系统
方法1 使用lsof命令
使用IPv4协议的局域网:
执行命令: lsof -Pnl +M -i4|grep 8080
输出结果: java 1419 1401 10u IPv4 6793357 TCP *:8080 (LISTEN)

方法2 先使用 netstat命令,再用 ps命令
执行命令: netstat -anp|grep 8080
输出结果: tcp 0 0 :::8080 :::* LISTEN 12006/java
执行命令: ps -ef | grep 12006
输出结果: root 12886 12851 0 Dec09 ? 00:01:14 /home/bjca/bea/jdk160_05/bin/java -client -Xms256m -Xmx512m -XX:Compile

猜你喜欢

转载自blog.csdn.net/qq649954944/article/details/79969337