Windows Linux的cmd命令查询指定端口占用的进程并关闭

以端口8080为例:

Windows 

1.查找对应的端口占用的进程:netstat  -aon|findstr  "8080",找到占用8080端口对应的程序的PID号;

2.根据PID号找到对应的程序:tasklist|findstr "PID号",找到对应的程序名;

3.结束该进程:taskkill /f /t /im 程序名 ;

 ----------------------------------------华丽的分割符--------------------------------------------

Linux

1.查找对应的端口占用的进程:lsof -i:8080,找到占用8080端口对应的程序的PID号(加入PID号是10016);

2.结束该进程:kill -9 10016 ;

注意空格

原文地址:https://www.cnblogs.com/renpei/p/9077717.html