日期:2014-05-16  浏览次数:20856 次

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

windows命令

?

杀死占用端的进程

1.查找占用端口号

C:\Documents and Settings\dell>netstat -ano|findstr "80"
? TCP??? 0.0.0.0:80???????????? 0.0.0.0:0????????????? LISTENING?????? 2592
? TCP??? 0.0.0.0:28029????????? 0.0.0.0:0????????????? LISTENING?????? 6052
? TCP??? 192.168.160.42:1862??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1867??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1876??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1888??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:1897??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1900??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:1913??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1917??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1922??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:2287??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:2900??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? UDP??? 127.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"
? TCP??? 0.0.0.0:28029????????? 0.0.0.0:0????????????? LISTENING?????? 6052
? TCP??? 192.168.160.42:1922??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1927??? 172.16.8.4:8080??????? TIME_WAIT?????? 0
? TCP??? 192.168.160.42:1967??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:1969??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:1973??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:1975??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:2287??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? TCP??? 192.168.160.42:2900??? 172.16.8.4:8080??????? ESTABLISHED???? 2568
? UDP??? 127.0.0.1:1078???????? *:*??????????????????????????????????? 3980
? UDP??? 127.0.0.1:2580???????? *:*??????????????????????????????????? 5560