1.先介绍几个命令: 1. lsof -i:80
查看80端口的占用情况
命令返回结果:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 46678 xiaoju 7u IPv4 3292095214
0t0 TCP *:http (LISTEN)
查看80端口服务端socket占用状况
netstat命令介绍见,其中注意有-a的时候-l过滤是无效的,所以要加-l就去掉-a。
命令返回结果:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 46678/nginx: worker
3. ll /proc/46778查看PID为46778的进程服务运行命令的目录和命令等信息
命令介绍见:https://www.douban.com/note/409387658/
2. 常见case: case1: 一台机器上启动了好多个shop服务,如下,想知道每个服务分别占用什么端口[xiaoju@rico-public order]$ ps -ef |grep shop xiaoju 15061 1 3 Jun12 ? 07:49:08 ./bin/shop -config=./conf/service.conf.dev.liantiao xiaoju 17279 1 3 17:54 ? 00:11:43 ./bin/shop -config=./conf/service.conf.dev xiaoju 19776 1 4 Jun15 ? 06:56:42 /home/xiaoju/shop/output/bin/shop -config=http://www.likecs.com/home/xiaoju/shop/output/conf/service.conf xiaoju 37919 1 2 Jun15 ? 03:14:06 ./bin/shop -config=http://www.likecs.com/home/xiaoju/shop_8407/output/conf/service.conf.dev.8407