有2种方法:
netstat
https://www.cnblogs.com/live41/p/14236549.html
或
lsof -i
https://www.cnblogs.com/live41/p/15481882.html
以上2个命令是通过查询网络堆栈列举正在监听网络的端口。示例:
netstat -anp | grep 3306 netstat -anp | grep ssh lsof -i | grep 3306 lsof -i | grep ssh