linux 与windows netstat命令查看端口是否占用

windows命令

杀死占用端的进程

1.查找占用端口号

C:\Documents and Settings\dell>netstat -ano|findstr "80"

TCP0.0.0.0:800.0.0.0:0LISTENING2592

TCP0.0.0.0:280290.0.0.0:0LISTENING6052

TCP192.168.160.42:1862172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1867172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1876172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1888172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:1897172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1900172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:1913172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1917172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1922172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:2287172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:2900172.16.8.4:8080ESTABLISHED2568

UDP127.0.0.1:1078*:*3980

  UDP    127.0.0.1:2580         *:*                                    5560

2.杀死进程,指定PID

C:\Documents and Settings\dell>tskill 2592

3.再次查询,已经被停止

C:\Documents and Settings\dell>netstat -ano|findstr "80"

TCP0.0.0.0:280290.0.0.0:0LISTENING6052

TCP192.168.160.42:1922172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1927172.16.8.4:8080TIME_WAIT0

TCP192.168.160.42:1967172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:1969172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:1973172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:1975172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:2287172.16.8.4:8080ESTABLISHED2568

TCP192.168.160.42:2900172.16.8.4:8080ESTABLISHED2568

UDP127.0.0.1:1078*:*3980

UDP127.0.0.1:2580*:*5560

相关推荐