一、lsof
# lsof -i
# lsof -i:80
二、使用netstat
# netstat -tunlp
# netstat -tunlp |grep 8002
yum install net-tools #没有netstat命令,用安装net-tools软件包
两者的区别:
1.netstat跟权限无关,能看到所有用户的端口占用情况,而lsof只能看到当前用户的占用情况;
2.losf能看到pid和用户,可以找到哪个进程占用了这个端口(其实netstat也能看,只是没losf明显)。