Summary of methods to check whether the port is open in Linux

Summary of methods to check whether the port is open in Linux

Method 1: Use lsof command

We can use the lsof command to check whether a port is open. The basic syntax is as follows:

lsof -i:port number

If there is no output, it means that the port number is not open.

The following figure takes port 80 and port 53 as an example to check whether port 80 and port 53 are open

You can also use the lsof -i command to directly output the open ports to check whether certain ports are open.

Method 2: Use the netstat command

The netstat command can provide network-related information about a host.

We can check the open ports in linux using netstat -atu

Netstat Flags We Use: -a, -t and -u Introduction

-a: All sockets.

-t : TCP connection of the program

-u: UDP connection for the program

You can also add the -p flag to display the associated PID of the process or program name.

To display only UDP ports, you can use the following command:

To display only TCP ports, you can use the following command:

You may also be interested in:
  • Three ways to check whether a port is open in a remote Linux system
  • Summary of Linux methods for detecting whether a remote port is open
  • Detailed explanation of Linux to view the open port number of the server
  • How to allow remote access to open ports in Linux

<<:  MySQL 5.7.17 installation and configuration tutorial under CentOS6.9

>>:  jQuery plugin to implement search history

Recommend

Mysql specifies the date range extraction method

In the process of database operation, it is inevi...

MySQL database aggregate query and union query operations

Table of contents 1. Insert the queried results 2...

Talking about the practical application of html mailto (email)

As we all know, mailto is a very practical HTML ta...

js Promise concurrent control method

Table of contents question background Idea & ...

Detailed explanation of CocosCreator Huarongdao digital puzzle

Table of contents Preface text 1. Panel 2. Huaron...

Realize map aggregation and scattering effects based on vue+openlayer

Table of contents Preface: Result: 1. Polymerizat...

The whole process of node.js using express to automatically build the project

1. Install the express library and generator Open...

DHCP Configuration Tutorial in CentOS7 Environment

Table of contents Configuration command steps in ...

JS generates unique ID methods: UUID and NanoID

Table of contents 1. Why NanoID is replacing UUID...

js to achieve the pop-up effect

This article example shares the specific code of ...

Detailed explanation of angular content projection

Table of contents Single content projection Multi...

Vue implements tree table through element tree control

Table of contents Implementation effect diagram I...