Check if the port is open in Linux.

In Linux systems, you can use the netstat command or the lsof command to check if a port is open.

  1. Use the netstat command:
netstat -tuln | grep <端口号>

The -t option displays only TCP protocol ports, the -u option displays only UDP protocol ports, the -l option shows only listening ports, and the -n option displays port numbers in numerical form.

  1. Use the lsof command:
lsof -i :<端口号>

The -i option is used to display only network-related information, followed by specifying the port number to be queried.

Both methods can be used to check if a specified port is open and display the corresponding service or process information.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds