Egi*_*gil 40
该/proc方法是检查exe在对应的PID的目录链接。
让我们举一个例子update-notifier:
找到 pid,在本例中为15421:
egil@gud:~$ ps x | grep update-notifier
2405 pts/4 S+ 0:00 grep update-notifier
15421 ? Sl 0:00 update-notifier
Run Code Online (Sandbox Code Playgroud)
查找符号链接:
egil@gud:~$ file /proc/15421/exe
/proc/15421/exe: symbolic link to `/usr/bin/update-notifier'
Run Code Online (Sandbox Code Playgroud)
N.N*_*.N. 16
也许which这就是你要找的。例如,在我的系统上
which firefox
Run Code Online (Sandbox Code Playgroud)
返回
/usr/bin/firefox
Run Code Online (Sandbox Code Playgroud)
另请参阅查找在 Solaris、Ubuntu、Suse 或 Redhat Linux 上运行的应用程序的路径。
如果您有可用的进程 ID,您可以使用:
readlink -f /proc/$pid/exe
Run Code Online (Sandbox Code Playgroud)
(替换$pid为进程的进程ID)
如果流程不属于您,则您必须将其放在sudo前面。
确定命令位置的示例firefox:
的输出ps ax -o pid,cmd | grep firefox:
22831 grep --color=auto firefox
28179 /usr/lib/firefox-4.0.1/firefox-bin
Run Code Online (Sandbox Code Playgroud)28179 是进程 ID,因此您必须运行:
readlink -f /proc/28179/exe
Run Code Online (Sandbox Code Playgroud)
输出:
/usr/bin/firefox
Run Code Online (Sandbox Code Playgroud)