1,netstat -an
2、lsof -i
The above two commands list the ports that are listening to the network by querying the network stack.
Check the monitoring information of the port.
Netstat -anp | grep port number
Lsof -i | grep port number
Secondly, use the port scanner nmap to check which ports are listening to the network.
Example: Determining which ports are listening for TCP connections from the network is:
Nmap -sT -O local host