Home > Operation and Maintenance > Linux Operation and Maintenance > What is the command to view ports in Linux?

What is the command to view ports in Linux?

coldplay.xixi
Release: 2022-04-12 18:05:35
Original
129351 people have browsed it

Linux command to view ports: 1. lsof command, syntax "lsof -i:port number", can check port occupancy; 2. "netstat -tunlp" command, can display tcp, udp ports and Process and other related situations, the syntax is "netstat -nltp | grep port number".

What is the command to view ports in Linux?

The operating environment of this tutorial: linux7.3 system, DELL G3 computer.

Linux command to view ports:

The first: lsof command

lsof(list open files) is a Lists the tools used to open files on the current system.

lsof can check the port occupancy

lsof -i:端口号
Copy after login

Example: Check the occupancy of the server 8000 port:

What is the command to view ports in Linux?

Second :netstat -tunlp command

netstat -tunlp is used to display tcp, udp ports and processes and other related conditions.

netstat -nltp | grep 端口号
Copy after login
  • -t (tcp) Show only tcp related options

  • -u (udp) Show only udp related options

  • -n Refuse to display aliases and convert all numbers that can be displayed into numbers

  • -l Only list the service status in Listen(listening)

  • -p Display the name of the program that establishes the relevant link

For example, to view the situation of port 8000, use the following command:

What is the command to view ports in Linux?

Several states of TCP connection

ESTABLISHED Established

CLOSED Closed

LISTENING Listening

FIN-WAIT-2 Wait for the connection to be closed

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

Related learning recommendations: linux video tutorial

The above is the detailed content of What is the command 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