LINUX Checks whether the port is occupied

LINUX Checks whether the port is occupied

I have never been able to figure out whether the port is occupied. After asking many people, I finally figured it out. Now let me summarize:

1.netstat -anp |grep port number

As follows, I take 3306 as an example, netstat -anp |grep 3306 (note here, I am operating as a normal user, so I added sudo. If you are operating as a root user, you can view it without adding sudo), as shown in Figure 1:

Figure 1

In Figure 1, the monitoring status is LISTEN, which means it is occupied. The last column shows that it is occupied by the service mysqld. Check the specific port number. As long as there is a line like the one in the figure, it means it is occupied.

2.netstat -nultp (no need to add port number here)

This command is used to view all currently used ports, as shown in Figure 2:

Figure 2

As you can see from the picture, my port 82 is not occupied.

3.netstat -anp |grep 82 to check the usage of port 82, as shown in Figure 3:

Figure 3

It can be seen that there is no LISTEN line, so it means that it is not occupied. Note that the LISTENING in the figure does not mean that the port is occupied. Do not confuse it with LISTEN. When checking the specific port, you must see the line of tcp, port number, and LISTEN to indicate that the port is occupied.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to release port occupation in Linux
  • Detailed example of Linux command to check port usage
  • Python writes a small program to detect Linux port usage

<<:  JavaScript style object and CurrentStyle object case study

>>:  Detailed tutorial on deploying Django project using Docker on centos8

Recommend

About scroll bar in HTML/removing scroll bar

1. The color of the scroll bar under xhtml In the ...

Solution to docker suddenly not being accessible from the external network

According to the methods of the masters, the caus...

Detailed description of component-based front-end development process

Background <br />Students who work on the fr...

Introduction to Common XHTML Tags

<br />For some time, I found that many peopl...

mysql solves time zone related problems

Preface: When using MySQL, you may encounter time...

Sample code for installing Jenkins using Docker

Two problems that are easy to encounter when inst...

Practice of implementing custom search bar and clearing search events in avue

Table of contents 1. Customize the search bar con...

Nginx sample code for implementing dynamic and static separation

In combination with the scenario in this article,...

About MySQL 8.0.13 zip package installation method

MySQL 8.0.13 has a data folder by default. This f...

Detailed tutorial on deploying Hadoop cluster using Docker

Recently, I want to build a hadoop test cluster i...

How to clear mysql registry

Specific method: 1. Press [ win+r ] to open the r...

Some problems you may encounter when installing MySQL

Question 1: When entering net start mysql during ...

Ubuntu 20.04 CUDA & cuDNN Installation Method (Graphical Tutorial)

CUDA installation download cuda Enter the nvidia-...