Windows and Linux view ports are occupied

Source: Internet
Author: User

This digest is written from:

Baidu Experience

Https://www.cnblogs.com/ieayoio/p/5757198.html

First, Windows: Start----> Run---->cmd, or the WINDOW+R key combination to bring up the command window

1, enter the command: Netstat-ano, list all the conditions of the port. In the list we look at the occupied port, such as 49157, and find it first. 2, view the occupied port corresponding PID, input command: Netstat-aon|findstr "49157", enter, note the last digit, namely PID, here is 2720. 3, continue to input tasklist|findstr "2720", enter, to see which process or program occupies 2720 ports, the result is: Svchost.exe 4, or we open the Task Manager, switch to the Process tab, In the PID column to see who the process is 2720, if you do not see the PID column, such as: 5, then we click on the view---> select column, the PID (process identifier) before the tick, click OK.

6, so we see the PID of this column identification, look at the 2720 corresponding process is who, if not, we put the following show all users of the process front of the tick, you can see, the image name is Svchost.exe, the description is, the main process of Windows, Fully consistent with the above command view.

7. End the process: Select the process in Task Manager to click the "End Process" button, or enter it in the cmd command window: taskkill/f/t/im Tencentdl.exe.

Second, Linux: View port usage

In the process of using a Linux system, there are times when the port is occupied and the service fails to start. For example, HTTP uses port 80, but when you start Apache, you find that the port is in use.

This situation is mostly due to software conflicts, or incorrect default port settings, and you need to see exactly which process is consuming the port to determine the further processing.

1. Check the Port occupancy command: lsof-i

This returns the current usage of all open ports on Linux. The first paragraph is the process, and the last column is the protocol to listen on, the IP and port number to listen to, and the state. If the port number is a known common service (such as 80, 21, and so on), the protocol name is displayed directly, such as HTTP, FTP, SSH, and so on.

2. Check the occupancy of one port: Lsof-i: Port number

This shows that port 21st is being used by PURE-FTPD and the state is listen.

3. End the process that occupies the port: Killall process Name

Although we do not recommend this way to solve the problem of conflict, but in some cases can also directly end the occupation process (such as restarting Apache when the process does not fully exit, resulting in a restart failure)

In this way, all the PURE-FTPD processes will be closed down.

4, you can also use the command: Netstat-apn|grep < port number > Example: Linux code [[email protected] user0]# netstat-apn|grep TCP 0 0::: ::* LISTEN 19408/java Find the process number, then use the following command to view more information: Ps-aux|grep < process number & Gt

Windows and Linux view ports are occupied

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.