Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of checking whether the Port is occupied under linux system

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to check whether the port is occupied in linux system. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

1. Use the netstat command

Netstat-anp | grep port number

As follows, take 3306 as an example, netstat-anp | grep 3306 (note here, the following is operated by ordinary users, so sudo is added. If you operate with root users, you can view it without adding sudo), as shown in figure 1 below:

The above figure mainly shows that the monitoring status of LISTEN indicates that it is occupied, and the last column shows that it is occupied by the service mysqld. Check the specific port number.

2. Use the following command

Netstat-nultp

This command is to view all currently used ports, as shown in the following figure:

You can see in the figure that port 82 is not occupied.

3. Use the following command

Netstat-anp | grep 82

View the usage of port 82, as shown in the following figure:

You can see that there is no LISTEN line, so it means it is not occupied.

Note here that the LISTENING shown in the figure does not mean that the port is occupied, so do not be confused with LISTEN. When viewing a specific port, you must see the line tcp, port number and LISTEN to indicate that the port is occupied.

The above is the method to check whether the port is occupied under the linux system. Is there anything to gain after reading it? If you want to know more about it, you are welcome to follow the industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report