Linux如何查看端口:
1. lsof -i:端口号 用于查看某一端口的占用情况,比如查看8000端口使用情况,lsof -i:8000
# lsof -i:8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
lwfs 22065 root 6u IPv4 4395053 0t0 TCP *:irdmi (LISTEN)
可以看到8000端口已经被轻量级文件系统转发服务lwfs占用;
2. netstat -tunlp |grep 端口号,用于查看指定的端口号的进程情况,如查看8000端口的情况,netstat -tunlp |grep 8000
# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 4814/rpcbind
tcp 0 0 0.0.0.0:5908 0.0.0.0:* LISTEN 25492/qemu-kvm
tcp 0 0 0.0.0.0:6996 0.0.0.0:* LISTEN 22065/lwfs
tcp