lsof -i 需要 root 用户的权限来执行
$ lsof -i:8000COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnodejs 26993 root 10u IPv4 37999514 0t0 TCP *:8000 (LISTEN)
netstat -tunlp 用于显示 tcp,udp 的端口和进程等相关情况。
$ netstat -tunlp | grep 8000tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 26993/nodejs$ netstat -tunlp | grep bystackdtcp6 0 0 :::9889 :::* LISTEN 3890567/bystackdtcp6 0 0 :::56658 :::* LISTEN 3890567/bystackdudp 0 0 0.0.0.0:5353 0.0.0.0:* 3890567/bystackdudp 0 0 0.0.0.0:5353 0.0.0.0:* 3890567/bystackdudp6 0 0 :::56658 :::* 3890567/bystackdudp6 0 0 :::5353 :::* 3890567/bystackdudp6 0 0 :::5353 :::* 3890567/bystackd
