Windows上
查看端口占用:
netstat -aon|findstr <端口号>
通过进程ID查询进程信息
tasklist | findstr <上一步查出来的进程号>
图例:

Linux 上
查看端口占用:
netstat -tuln | grep <端口号>
lsof -i:<端口号>
ss -tlnp | grep <端口号>
多种方式,但前提是要安装了相应工具,如: sudo apt-get install netstat
本文介绍了在Windows和Linux系统中,使用netstat、tasklist、lsof、ss等命令行工具查看和管理端口占用的方法,包括通过进程ID查询以及在Linux中可能需要额外安装netstat的情况。
Windows上
查看端口占用:
netstat -aon|findstr <端口号>
通过进程ID查询进程信息
tasklist | findstr <上一步查出来的进程号>
图例:

Linux 上
查看端口占用:
netstat -tuln | grep <端口号>
lsof -i:<端口号>
ss -tlnp | grep <端口号>
多种方式,但前提是要安装了相应工具,如: sudo apt-get install netstat
5万+
579
1231
7204

被折叠的 条评论
为什么被折叠?