Linux通过进程id查看执行源文件位置.
以nginx进程为例.
1.找到nginx进程id,进程id为9932
ps -ef|grep nginx root 9932 1 0 4月26 ? 00:00:26 nginx: master process /www/wdlinux/nginx/sbin/nginx -c /www/wdlinux/nginx/conf/nginx.conf root 16200 15857 0 10:57 pts/0 00:00:00 grep --color=auto nginx www 23328 9932 0 02:30 ? 00:00:03 nginx: worker process www 23329 9932 0 02:30 ? 00:00:02 nginx: worker process www 23330 9932 0 02:30 ? 00:00:03 nginx: worker process www 23331 9932 0 02:30 ? 00:00:02 nginx: worker process
2.查找运行进程的源文件位置
[root@ebs-26562 ~]# ls /proc/9932/exe 279823378 lrwxrwxrwx 1 root root 0 2022-05-14 10:55 /proc/9932/exe -> /www/wdlinux/nginx-1.8.1/sbin/nginx