How windows and liunx check and close the port number

1. Windows closes the port number

1. The known port number is 6379, execute the command netstat -aon|findstr 6379 to check that the occupied process is 240996

C:\Users\yanghaichao01>netstat -aon|findstr 6379
  TCP    0.0.0.0:6379      0.0.0.0:0      LISTENING       2772
  TCP    [::]:6379         [::]:0         LISTENING       2772

2. Execute the command tasklist|findstr 2772 to find the corresponding program name

C:\Users\yanghaichao01>tasklist|findstr 2772
redis-server.exe     2772 Console      1     63,888 K

3. Execute taskkill -pid 2772 -F to close

C:\Users\yanghaichao01>netstat -aon|findstr 6379
  TCP    0.0.0.0:6379  0.0.0.0:0   LISTENING       26796
  TCP    [::]:6379    [::]:0       LISTENING       26796

C:\Users\yanghaichao01>tasklist|findstr 26796
redis-server.exe    26796 Console         1     63,840 K

C:\Users\yanghaichao01>taskkill -pid 26796 -F
成功: 已终止 PID 为 26796 的进程。

2. Liunx closes the port number

lsof -i: port number
kill -9 process number

One development engineer is also in the continuous learning stage, and the usual small experiences are shared from time to time. I hope that those who read the text I wrote can avoid detours and wish you success in work and study.
Bloggers have limited experience, if there are any shortcomings, welcome to communicate and improve together~ I hope to make progress together with you who are also in CSDN.

Author | Sweet Little Sweet Potato
Produced | Little Sweet Potato

Guess you like

Origin blog.csdn.net/qq_36836370/article/details/130600032