Check whether the port number is in use (condition command)

Source: Internet
Author: User

Netstat-ano

We can know that a port is occupied by that process (corresponding to the PID;
Then we can open the task manager and view the process name corresponding to a PID;
If the PID is not displayed, choose "View"> "Select column"> "PID;
After learning about a process, we can kill the process and modify the port used by the process.

 

If we need to determine who occupies our port 9050

1. Windows Platform
Run the following command in the Windows command line window:
C:/> netstat-Aon | findstr" 9050"
TCP 127.0.0.1: 9050 0.0.0.0: 0 listening 2016

As you can see, the port is occupied by a process with the process number 2016. Continue to execute the following command:

C:/& gt; tasklist | findstr "2016"
Tor.exe 2016 console 0 16,064 K

You know, tor occupies your port.

 

2. Aix
$ Netstat-aan | grep 30542
Fda-f303321b58 tcp4 0 0 *. 30542 *. * listen
$ Rmsock fda-f303321b58 tcpcb
The socket 0x3321800 is being held by proccess 692476 (db2sysc ).

I will not explain this.

 

3. Linux
$ Netstat-Pan | grep 2809
TCP 0 0 0.0.0.0: 2809 0.0.0.0: * Listen 9493/Java
Del. icio. us tags: Aix, windows, tips

 

 

 

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. Executable components are known in some cases
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
In the [] at the bottom, the top is the component it calls, and so on until the TCP/IP part. Note this option
It may take a long time. If you do not have sufficient permissions, it may fail.

-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 shows 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, the IP address,
Statistics of IPv6, ICMP, ICMPv6, TCP, tcpv6, UDP, and udpv6;
The-P option is used to specify the default subset.

-V and-B options will be included in
Creates a connection or listener port for All executable components.

Interval re-displays the selected statistics.
Pause interval (in seconds ). Press Ctrl + C to stop and restart
Displays statistics. If omitted, netstat displays the current
Configuration Information (only once)

This article from the hacker base-the world's largest Chinese hacker site Source: http://www.hackbase.com/tech/2009-05-18/52801.html

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.