Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have multiple copies of the same app on the disk, and only one is running, as I can see with ps, how can I know the absolute path to distinguish from the others?

share|improve this question
up vote 49 down vote accepted
% sudo ls -l /proc/PID/exe


% ps -auxwe | grep 24466
root     24466  0.0  0.0   1476   280 ?        S     2009   0:00 supervise sshd
% sudo ls -l /proc/24466/exe
lrwxrwxrwx 1 root root 0 Feb  1 18:05 /proc/24466/exe -> /package/admin/daemontools-0.76/command/supervise
share|improve this answer
In my system (ubuntu 14.04) you do not have to be superuser to run the ls command. – jarno Mar 5 at 8:42
@jarno ls: cannot read symbolic link /proc/28783/exe: Permission denied -- it's not about running the ls command, it's about accessing the process info of a process not belonging to you. On my box, about 97% of all processes listed in /proc are root processes, and the others are distributed over 11 different users. – Irfy Mar 21 at 12:53

One way is ps -ef

share|improve this answer
didn't work for a specific service, it just provide the relative path – Jader Dias Feb 1 '10 at 16:57
Helped me identify a process via the command it was started with. – jpierson Feb 9 at 18:50
pwdx $pid

This gives you the Current Working Directory of the pid, not its absolute path. usually the which command will tell you which is being invoked from the shell.

#>which vlc
share|improve this answer
this answer need more upvote.. – Kokizzu Jan 30 '15 at 3:02
@Kokizzu No, it doesn't because it doesn't answer the question at all. The which command only tells you which binary will be run if you execute the command now. The question was "which binary is already running there". Imagine for example having a dozen jdks on your computer. If you want to know for a running java process which jdk it's been taken from, which doesn't help you with that. It will only tell you which jdk it will be taken from, if you execute it now. The accepted answer is also the correct one. – noamik Feb 18 at 9:05

The quick answer is to use ps with options or the /proc filesystem info. That will usually work, but is not guaranteed. In general, there is no definite, guaranteed answer. For instance, what if the executing file is deleted during execution, so that there is no path to the file?

See the Unix FAQ for a little more detail, particularly questions 4.3 and 4.4.

share|improve this answer
ps auxwwwe


share|improve this answer
does not show ALL full qualified paths on my linux: "root 24466 0.0 0.0 1476 280 ? S 2009 0:00 supervise sshd " for example – akira Feb 1 '10 at 17:04

You could use

readlink /proc/$(pgrep -x -U $(id -ur) APP_NAME)/exe


find /proc/$(pgrep -x -U $(id -ur) APP_NAME)/exe -printf "%l\n"

to get the absolute path. PID is the process.

share|improve this answer

Why does everyone expect you to know the PID? Here's the human-friendly way:

pwdx `pgrep ###process_name###`
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .