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

Docker builds cluster MongoDB implementation steps

Preface Due to the needs of the company's bus...

A brief discussion on the design of Tomcat multi-layer container

Table of contents Container Hierarchy The process...

Docker runs operations with specified memory

as follows: -m, --memory Memory limit, the format...

Various correct postures for using environment variables in Webpack

Table of contents Write in front Business code us...

Web front-end development experience summary

XML files should be encoded in utf-8 as much as p...

How to remotely connect to the cloud server database using Navicat

It is very convenient to connect to a remote serv...

A brief discussion on how to customize the host file in Docker

Table of contents 1. Command 2. docker-compose.ym...

Getting Started Tutorial on GDB in Linux

Preface gdb is a very useful debugging tool under...

How to use cookies to remember passwords for 7 days on the vue login page

Problem Description In the login page of the proj...

Front-end JavaScript housekeeper package.json

Table of contents 1. Required attributes 1. name ...

Nginx 502 Bad Gateway Error Causes and Solutions

I have encountered the Nginx 502 Bad Gateway erro...

MySQL turns off password strength verification

About password strength verification: [root@mysql...

Several ways to implement "text overflow truncation and omission" with pure CSS

In our daily development work, text overflow, tru...