Home >Operation and Maintenance >Linux Operation and Maintenance >What are the commands to view ports in Linux?
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.
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
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!