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

How to check Port occupancy under Linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to check port occupancy under Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

You can use the lsof and netstat commands to view port occupancy on a Linux system.

1. Lsof-I: the port number is used to view the occupancy of a port, for example, to check the usage of port 8000, and lsof-i 8000.

# lsof-i:8000COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMElwfs 22065 root 6u IPv4 4395053 0t0 TCP *: irdmi (LISTEN)

You can see that port 8000 has been occupied by the lightweight file system forwarding service lwfs

2. Netstat-tunlp | grep port number, which is used to view the progress of the specified port number. For example, for port 8000, netstat-tunlp | grep 8000

# netstat-tunlpActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0 0 only servers 111 0.0.0 0 LISTEN 4814/rpcbind tcp 00 0.0.0 0 5 908 0. 0.0.0 * LISTEN 25492/qemu-kvm tcp 0 0 0.0.0.0 LISTEN 6996 0.0.0.0 LISTEN 22065/lwfs tcp 0 192.168.122.1 38296/dnsmasq tcp 0 0 0.0.0.0 LISTEN 5013/cupsd tcp 22 0.0.0.0 LISTEN 5013/cupsd tcp 0 0 127 .0.0.1: 25 0.0.0.0 LISTEN 5962/master tcp 00 0.0.0.015 8666 0.0.0.0 LISTEN 44868/lwfs tcp 00 0.0.0.0000 0. 0.0.0grep 8000tcp * LISTEN 22065/lwfs# netstat-tunlp | grep 8000tcp 00 0.0.0.0pur8000 0.0.0.0purl * LISTEN 22065/lwfs

Explain the meaning of several parameters:

-t (tcp) shows only tcp-related options-u (udp) shows only udp-related options-n refuses to show aliases, can display all numbers converted to numbers-l lists only the service status in Listen (monitoring)-p shows the name of the program that established the relevant link

This is the end of this article on "how to check port occupation under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

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

Development

Wechat

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

12
Report