在linux環(huán)境下如何查看進(jìn)程的全路徑
Posted on 2014-03-19 17:21 泰仔在線 閱讀(4097) 評(píng)論(0) 編輯 收藏 所屬分類: Linux 相關(guān)一般用過linux的人都知道ps -ef|grep XXX
可是用ps看到的不是全路徑,
ps -ef|grep http
500 5948 15608 0 18:09 pts/0 00:00:00 grep http
root 31723 1 0 Mar06 ? 00:00:01 httpd
500 31725 31723 0 Mar06 ? 00:00:01 httpd
那如何查看進(jìn)程的全路徑呢?
其實(shí)每個(gè)進(jìn)程啟動(dòng)之后在 /proc下面有一個(gè)于pid對(duì)應(yīng)的路徑
例如上面的
ps -ef|grep http
顯示:root 31723 1 0 Mar06 ? 00:00:01 httpd
31723就是進(jìn)程號(hào)
到/proc/31723下,ll(或者ls -l)會(huì)看到:
# ll /proc/31723
總用量 0
dr-xr-xr-x 2 root root 0 3月 19 18:13 attr
-r-------- 1 root root 0 3月 19 18:13 auxv
-r--r--r-- 1 root root 0 3月 19 18:04 cmdline
-rw-r--r-- 1 root root 0 3月 19 18:13 coredump_filter
-r--r--r-- 1 root root 0 3月 19 18:13 cpuset
lrwxrwxrwx 1 root root 0 3月 19 18:13 cwd -> /
-r-------- 1 root root 0 3月 19 18:13 environ
lrwxrwxrwx 1 root root 0 3月 19 18:13 exe -> /usr/sbin/httpd
dr-x------ 2 root root 0 3月 19 18:13 fd
......
其中的exe,就是你要查找的進(jìn)程所在路徑了。
可是用ps看到的不是全路徑,
ps -ef|grep http
500 5948 15608 0 18:09 pts/0 00:00:00 grep http
root 31723 1 0 Mar06 ? 00:00:01 httpd
500 31725 31723 0 Mar06 ? 00:00:01 httpd
那如何查看進(jìn)程的全路徑呢?
其實(shí)每個(gè)進(jìn)程啟動(dòng)之后在 /proc下面有一個(gè)于pid對(duì)應(yīng)的路徑
例如上面的
ps -ef|grep http
顯示:root 31723 1 0 Mar06 ? 00:00:01 httpd
31723就是進(jìn)程號(hào)
到/proc/31723下,ll(或者ls -l)會(huì)看到:
# ll /proc/31723
總用量 0
dr-xr-xr-x 2 root root 0 3月 19 18:13 attr
-r-------- 1 root root 0 3月 19 18:13 auxv
-r--r--r-- 1 root root 0 3月 19 18:04 cmdline
-rw-r--r-- 1 root root 0 3月 19 18:13 coredump_filter
-r--r--r-- 1 root root 0 3月 19 18:13 cpuset
lrwxrwxrwx 1 root root 0 3月 19 18:13 cwd -> /
-r-------- 1 root root 0 3月 19 18:13 environ
lrwxrwxrwx 1 root root 0 3月 19 18:13 exe -> /usr/sbin/httpd
dr-x------ 2 root root 0 3月 19 18:13 fd
......
其中的exe,就是你要查找的進(jìn)程所在路徑了。