linux下进程、端口号相互查看方法 linux下通过进程名查看其占用端口: 1、先查看进程pid ps -ef | grep 进程名
2、通过pid查看占用端口 netstat -nap | grep 进程pid
例:通过nginx进程查看对应的端口号
#查看nginx进程pid: 命令: ps -ef | grep nginx 结果: root 9836 1 0 Jul11 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 9841 9836 0 Jul11 ? 00:00:09 nginx: worker process
#通过nginx进程pid查看占用端口(进程pid为9836) 命令: netstat -nap | grep 9836 结果: tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 9836/nginx tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 9836/nginx tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 9836/nginx tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 9836/nginx
linux通过端口查看进程: netstat -nap | grep 端口号
-p 显示端口进程
例:查看8081号端口对应的进程名
命令: netstat -nap | grep 8081 结果: tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 9836/nginx
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有