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

How to check whether a specified port is open in Linux

王林
王林Original
2019-12-25 17:38:326198browse

How to check whether a specified port is open in Linux

First we open the command operation interface of Linux where we want to view the port, as shown in the figure (taking Ubuntu system as an example)

How to check whether a specified port is open in Linux

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

How to check whether a specified port is open in Linux

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

Recommended related video tutorials: linux video tutorial

How to check whether a specified port is open in Linux

If there is no output, it means that the port number is not enabled. To facilitate testing, I will detect an open port number here, and the information as shown in the figure will be output

How to check whether a specified port is open in Linux

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

How to check whether a specified port is open in Linux

The command shown in the picture is to view all open port numbers in the system. Port number using udp protocol

How to check whether a specified port is open in Linux

Then this command is to view the port number information using tcp protocol in the system

How to check whether a specified port is open in Linux

Recommended related articles and tutorials: linux tutorial

The above is the detailed content of How to check whether a specified 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