查看端口是否有程序使用

1
2
3
netstat -anp | grep :80  # 所有与80有关的端口

lsof -i:80 # 只看80端口

查看指定程序的进程

1
2
3
ps -ef | grep nginx

ps -C nginx -o pid # 查看pid