查找制定端口号的进程对应的可执行文件的详细目录

来源:互联网 发布:苹果淘宝旗舰店是官方 编辑:程序博客网 时间:2024/05/01 05:09

事件起因:

查找制定端口号的进程对应的可执行文件的详细目录。


解决方案:

1. 首先根据端口号8080查找进程号:

# netstat -anp|grep 8080tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      2047/nginx 
可以知道进程号是2047。

2. 根据进程号2047查找具体的执行命令:

# ps aux|grep 2047root      2047  0.0  0.0  20192   680 ?        Ss   08:40   0:00 nginx: master process /usr/local/nginx/sbin/nginxroot     20528  0.0  0.0 103240   884 pts/3    S+   14:21   0:00 grep 2047
即可得到可执行文件的名称及路径:nginx: master process /usr/local/nginx/sbin/nginx


ref:linux-netstat    linux-ps


0 0
原创粉丝点击