In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to query the port in linux". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "how to query the port in linux" can help you solve the problem.
Linux query port method: 1, use the netstat command, syntax "netstat [- acCeFghilMnNoprstuvVwx] [- A] [--ip]"; 2, use the ss command to display detailed TCP and connection status information; 3, use the lsof command.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux query port
Use netstat to check the port
Netstat is a command line tool that provides information about network connections.
To display all open ports, use the following command: netstat-anp
To list all TCP or UDP ports that are listening, including services that use port and socket status, use the following command: netstat-tunlp
The options used in this command have the following meanings:
-t-displays the TCP port. -u-displays the UDP port. -n-displays a numeric address instead of a hostname. -l-only the listening port is displayed. -p-displays the PID and name of the process. This information appears only if you run the command as root or sudo.
Query the specified port and filter through grep: netstat-tnlp | grep: 80
Show an example:
Note: Proto-the protocol used by the socket. Local Address-the IP address and port number on which the process listens. PID/Program name-PID and process name.
Use ss to check the port
Ss is the new netstat, with roughly the same command options. It lacks some netstat functionality, but exposes more TCP status, and is slightly faster.
Use example: ss-tunlp
Use lsof to check the port
Lsof is a powerful command-line utility that provides information about files opened by a process.
In Linux, everything is a file, and sockets can be thought of as files written to the network.
To use lsof to get a list of all listening TCP ports: lsof-nP-iTCP-sTCP:LISTEN
The options used are as follows:-n-do not convert the port number to the port name. -p-do not resolve the hostname, display the numeric address. -iTCP-sTCP:LISTEN-displays only network files with the TCP protocol status of LISTEN.
Examples of use:
To find a process that is listening on a specific port, such as 3306, use the following command: sudo lsof-nP-iTCP:3306-sTCP:LISTEN
This is the end of the content about "how to query the port of linux". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.