Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

In *nix you can use ps to see which process are running. But if an executable has multiple homonimous files in a device, we can't figure where it was invoked from.

This is slightly different from my last question on this subject. How can I know the absolute path of a running process?

share|improve this question
up vote 16 down vote accepted

Try this:

ls -l /proc/<PID>/cwd
share|improve this answer

Derived rom HUB's answer:

readlink /proc/<PID>/cwd

or even

readlink /proc/$(pgrep <program_name>)/cwd
share|improve this answer
+1 The output of readlink can be parsed better in a script. – Marco Leogrande Nov 21 '12 at 6:34

You can't tell where a process was invoked from, only where it currently is. Look at the cwd ("current working directory") link instead of exe.

share|improve this answer

I guess this command should work. It is a little workaround but it works at least on my machine.

for strlist in $(ps e PID);do if [ ${strlist:0:4} = "PWD=" ]; then echo ${strlist:4};fi;done

share|improve this answer

When I ran

ps auxwwwe | grep executableName > dump
vim dump

I was able to look for the part of the path I knew, and then I found out from which subdirectory the command was invoked from

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.