mac/linux查询网络端口占用

参考:http://www.cnblogs.com/kaiye/archive/2013/05/25/3099393.html

netstat命令

netstat -an|grep 8080

lsof命令

通过list open file命令可以查看到当前打开文件,在linux中所有事物都是以文件形式存在,包括网络连接及硬件设备

lsof -i:80  

-i表示网络连接  :80指明端口号,该命令会同时列出PID

-h获取lsof的帮助

查看所有进程监听的端口

 sudo lsof -i -p | grep -i "listen"
原文地址:https://www.cnblogs.com/dashuai01/p/6700475.html