Home > Operation and Maintenance > Linux Operation and Maintenance > What are the commands to view ports in Linux?

What are the commands to view ports in Linux?

coldplay.xixi
Release: 2020-12-22 16:07:50
Original
10769 people have browsed it

Linux command to view ports: 1. [a] Displays all connections and listening ports of this machine; 2. [n] In the form of network IP address, displays the currently established effective connections and ports; 3. [ r] displays routing table information; 4. [s] displays statistical information by protocol; 5. [v] displays currently valid connections.

What are the commands to view ports in Linux?

Linux command to view the port:

First type:

lsof -i:Port number

Second type:

netstat -nltp | grep port number

  • - a: Display all connections and listening ports of this machine

  • -n: In the form of network IP address, display the currently established effective connections and ports

  • -r: Display routing table information

  • -s: Display statistical information by protocol

  • -v: Display currently valid connections

  • -t: Display all TCP protocol connections

  • -u: Display all UDP protocol connections

  • -i: Display the status of the automatically configured port

  • -l: Only display the service network status with the connection status of listening

  • -p: Display pid/program name

Several statuses of TCP connection

  • ESTABLISHED Established

  • CLOSED Closed

  • ##LISTENING Listening

  • FIN-WAIT-2 Waiting for the connection to be closed

  • TIME-WAIT Wait enough time to ensure that the server closes the connection normally

The above is the detailed content of What are the commands to view ports in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template