Window: query which program occupies the port number. Linux: query which program occupies the port number. AIX: query which program occupies the port number.

Source: Internet
Author: User

1. In Windows, query the port occupation and clearing the port occupation programs

1. query the process ID occupied by the port

Click "start" --> "run", enter "cmd", and click "OK" to enter the DOS window. Then run the following commands respectively:

Netstat-a-n port usage
Netstat-ano port occupation and process PID
Netstat-Aon | findstr "80"
C: \ Users \ ADMIN> netstat-Aon | findstr "80"
TCP 127.0.0.1: 9080 0.0.0.0: 0 listening 4632

2. view the application corresponding to the port number
Tasklist | findstr" 4632"
Groove. EXE 4632 console 1 84,880 K
Obviously, groove. EXE occupies port 80, and groove. EXE is an IE ActiveX control.

3. Terminate the process
Taskkill, PID 4632, and F
Or useTaskkill/F/T/IM groove.exe

Re-query whether termination is successful

Tasklist | findstr" 4632"
If null is returned after the command is successfully terminated, the process with PID 4632 is terminated.

2. in Linux, query the port occupation and clearing the port occupation program.

1. query the port usage and view the process information based on the port

[Root @ server2 ~] #Lsof-I: 80
Command PID user FD type device size node name
Httpd5014Root 3u IPv4 14346 TCP server2: HTTP (Listen)

2. view the executable program corresponding to the process according to the process number

PS-F-p process number # PS-F-P 5014
Uid pid ppid C stime tty time cmd
Root 5014 1 0? 00:00:00/usr/local/Apache/bin/httpd-K
3. view the dynamic link based on the executable program
LDD Executable File Name

 LDD/usr/local/Apache/bin/httpd
Linux-vdso.so.1 => (0x00007fff9dc90000)
Libaprutil-0.so.0 = & gt;/usr/local/Apache/lib/libaprutil-0.so.0 (0x00002af026fcd000)
4. obtain detailed information about the processes occupied by the port number.

Netstat-tlnp | grep 80
TCP 0 0 192.168.33.10: 80 0.0.0.0: * Listen 5014/httpd
TCP 0 0 0.0.0.0: 48054 0.0.0.0: * Listen 5386/Java

This step is equivalent to the two steps above.

5. query the process ID occupied by the port number.

Netstat-tlnp | grep 80 | awk '{print $7}' | awk-F'/''{print $1 }'
5014
Or use the following command

Netstat-Pan | grep 80

Netstat [-A] [-B] [-E] [-N] [-O] [-P proto] [-R] [-S] [-V] [Interval]
-A displays all connection and listening ports.
-B shows the executable components that contain each connection or listening port. In some cases, it is known that the executable component has multiple independent components, and in these cases, the component sequence that includes creating a connection or listening port is displayed. In this case, the executable component name is in the [] at the bottom, and the component called by the component is at the top until the TCP/IP part. Note that this option may take a long time and may fail if you do not have sufficient permissions.

-E displays Ethernet statistics. This option can be combined with the-s option.
-N: the address and port number are displayed in numbers.
-O displays the ID of the process associated with each connection.
-P proto indicates the connection of the Protocol specified by Proto. proto can be one of the following protocols: TCP, UDP, tcpv6, or udpv6. If used with the-s option to display statistics by Protocol, proto can be one of the following protocols: IP, IPv6, ICMP, ICMPv6, TCP, tcpv6, UDP, or udpv6.
-R shows the route table.
-S displays statistics by protocol. By default, statistics of IP, IPv6, ICMP, ICMPv6, TCP, tcpv6, UDP, and udpv6 are displayed;
The-P option is used to specify the default subset.
When used together with option-B, components that contain connection or listening ports are displayed for All executable components.
Interval re-displays the selected statistics. The pause interval between each display (in seconds ). Press Ctrl + C to stop displaying statistics again. If omitted, netstat displays the current configuration information (only once)

6. One-time clearing of programs occupying port 80

Lsof-I: 80 | grep-V "PID" | awk '{print "Kill-9", $2}' | sh

7. Manually terminate the process

Kill5014
If it cannot be terminated, it can be forcibly terminated.

Kill-95014

Lsof-I: 80

The occupied process should not be queried.

Iii. Occupation of the port number queried by the AIX System

Netstat-aan | grep 80

Related Article

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.