How do I determine the path to a binary of a process?
The /proc
way would be to inspect the exe
link in the directory corresponding to the pid.
Let's take an example with update-notifier
:
Find the pid, which is 15421 in this example:
egil@gud:~$ ps x | grep update-notifier
2405 pts/4 S+ 0:00 grep update-notifier
15421 ? Sl 0:00 update-notifier
Look up the symbolic link:
egil@gud:~$ file /proc/15421/exe
/proc/15421/exe: symbolic link to `/usr/bin/update-notifier'
Maybe which
is what you are looking for. For instance, on my system
which firefox
returns
/usr/bin/firefox
See also Find Path of Application Running on Solaris, Ubuntu, Suse or Redhat Linux .
Providing you've a process ID available, you can use:
readlink -f /proc/$pid/exe
(replace $pid
by the process ID of a process)
If the process is not owned by you, you'll have to put sudo
in front of it.
An example for determining the location of the command firefox
:
-
The output of
ps ax -o pid,cmd | grep firefox
:22831 grep --color=auto firefox 28179 /usr/lib/firefox-4.0.1/firefox-bin
-
28179
is the process ID, so you've to run:readlink -f /proc/28179/exe
which outputs:
/usr/bin/firefox