Home>Article>Operation and Maintenance> How to check if a port is open in Linux
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.
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
2. Then in order to obtain higher Permissions (view all ports), switch to root user login here
3. The first method is to use the lsof -i:port number command line, taking 80 as an example , as shown in the figure
#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
5. The second method is to use the netstat -aptn command line to view all open port numbers,
6. The command shown in the figure is to view all port numbers using the udp protocol in the system.
7. Then this command is to view the system Use the port number information of the tcp protocol
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!