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 view the listening port under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to view the port being monitored under Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

First of all, you must know that the port does not exist independently, it is attached to the process. When a process is opened, its corresponding port is opened, and when the process is closed, the port is closed. The next time a process is opened again, the corresponding port will be opened again. It should not be simply understood as shutting down a port, but you can disable a port.

\ 1. You can use "netstat-anp" to see which ports are open.

(note: adding the parameter-n will convert the application to port display, that is, addresses in numeric format, such as nfs- > 2049 and ftp- > 21, so you can open two terminals and correspond to the corresponding port numbers of the program one by one.)

\ 2. You can then use "lsof-I: to see the program that applies the port (PORT refers to the corresponding port number)." Or you can check the file / etc/services, from which you can find out the service corresponding to the port. (note: some ports cannot be found by netstat, a more reliable method is "sudo nmap-sT-O localhost")\ 3. To close a port, you can: 1) disable the port through the iptables tool, such as "sudo iptables-An INPUT-p tcp-dport PORT-j DROP" 2) or turn off the corresponding application, and the port shuts down naturally. For example: "kill-9 PID" (PID: process number) such as: through "netstat-anp | grep ssh", there is a display: tcp 0 127.0.1 PID 2121 0.0.0.0 anp * LISTEN 7546/ssh: "kill-9 7546"

The above is all the contents of the article "how to check the port you are listening to under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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