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

Linux development: view port occupancy under Linux

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

Share

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

Some time ago, a student asked how to check the ports that have been occupied in the linux system. Let's give you a unified explanation.

When it comes to ports, let's first review the port definition. In order to distinguish which task the packets received by a host should be transferred to for processing, use the port number to distinguish; we know that the UDP port number is independent of the TCP port number, that is to say, TCP and UDP can use the same port number. As we all know, the port number less than 5000 is occupied, so how to check the port number that has been occupied?

The first one: view through the command

1.netstat-ntulp: view all occupied ports

The processes in which a port is occupied are listed in the last column of the list.

Where:

-t: indicates that the TCP port is displayed

-u: indicates that the UDP port is displayed

-l: display only listening sockets (sockets are programs that enable applications to read, write and send and receive protocol and data)

-p: displays the process identifier and program name, and each socket / port belongs to a program.

-n: show IP without DNS polling (operation can be accelerated)

Note when using: add sudo under ordinary users.

2.netstat-ntulp | grep port number: you can view a specific port number.

Use the netstat and grep commands to combine to view the port you want to view

The second kind: view through the file

Vi / etc/services: view ports that have been used

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