Get the App
SLTechnology News&Howtos  ›  Servers  › 

How Widows and Linux view and operate port methods

Shulou Source: shulou.com Published: 2022-06-02 00:35:34 10月02日 Update

This article mainly introduces Widows and Linux how to view and operate the port method, has a certain reference value, friends in need can refer to. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Open cmd

1.netstat-n

View all ports used on this computer

①. Proto indicates that there are two protocols: tcp and udp

②. Local Address represents the native IP, followed by the port number we use

③ .Foreign Address connects to the IP address of the outside server and the server port

④. State: indicates some specific state, such as: LAST_ACK waiting for the packet used to die

two。 Confirm the port number to be queried

Command netstat-aon | findstr 1044 (specified port number)

The last number of the query result is the pid of the current program or service.

3. Enter the command: tasklist | findstr 2612 (enter the pid queried above)

So you can view the programs running on this port.

Then query from the task manager, you can see the program

4. If we use the specified port number, two schemes

1. End the program running on this port in Task Manager, and then you can use this port number.

two。 Then enter the command in the cmd interface: taskkill / f / pid 2612 (enter the query pid), you can also kill this program

Linux

Netstat-tln # finds all occupied ports

Netstat-tln | grep 80 # find the specified occupied port

Install lsof

Yum install lsof

Through lsof, we can know which program our port belongs to.

Lsof-I: 80 # query port

Kill-9 # Kill process id multiple processes ID is separated by spaces

Thank you for reading this article carefully. I hope it is helpful for everyone to share how Widows and Linux view and operate port methods. At the same time, I also hope you can support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you!

Tags: Port program query slogan input method command article service task server process native management run two value content at the same time address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker MariaDB MySQL vpn