Home  >  Article  >  Operation and Maintenance  >  How to check if a port is open in Linux

How to check if a port is open in Linux

coldplay.xixi
coldplay.xixiOriginal
2020-12-30 11:38:5749838browse

Linux method to check whether the port is open: first open the port and switch to root user login; then use the [lsof -i:] port number command line; finally use the [netstat -aptn] command line to view all open The port number.

How to check if a port is open in Linux

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

Linux method to check whether the port is open:

1. First, we open the Linux command operation interface to view the port, as shown in the figure

How to check if a port is open in Linux

2. Then in order to obtain higher Permissions (view all ports), switch to root user login here

How to check if a port is open in Linux

3. The first method is to use the lsof -i:port number command line, taking 80 as an example , as shown in the figure

How to check if a port is open in Linux

#4. If there is no output, it means that the port number is not opened. In order to facilitate testing, I will detect an open port number here, and it will output The information shown in the figure

How to check if a port is open in Linux

5. The second method is to use the netstat -aptn command line to view all open port numbers,

How to check if a port is open in Linux

6. The command shown in the figure is to view all port numbers using the udp protocol in the system.

How to check if a port is open in Linux

7. Then this command is to view the system Use the port number information of the tcp protocol

How to check if a port is open in Linux

8. Finally, there is a client test method, which is to use the Telnet ip port number command, but I am in the virtual machine Linux The test was not successful. The test was successful on the remote Linux system. I don’t know what happened.

Related learning recommendations: linux video tutorial

The above is the detailed content of How to check if a port is open in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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