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

Is it possible, using ps, to determine where a process is running from?

I have two applications, both are identical and running in parallel directories, such as /app1/ and /app2/ If I run ps -ef then I'm unable to tell the difference between the two

Using ps (or alternative), how can I tell that PID 123 belongs to app1?

share|improve this question
up vote 5 down vote accepted

Some examples:

Current process list presented in tree hierarchy and wide output (showing the full command line arguments and not cutting them after X characters) ps -auxwwwf

Command pstree, show all processes and their process id's: pstree -ap

Or, if you are only interested in PIDs: pgrep -f app1 would list you all the PIDs for the processes matching pattern app1 somewhere along their name, command line arguments or path.

share|improve this answer
pgrep works for me. I'll have to predefine which PIDs are excluded from killing, but that'll work. thanks – user155695 Nov 10 '10 at 10:54
Great. :) Remember, there's also pkill which works the same way than pgrep, but instead of grep it kills. – Janne Pikkarainen Nov 10 '10 at 10:58

Also look at the /proc/ filesystem. In /proc/*pid* you have:

  • exe which is a symlink to the executable binary. In case of a script, this is the interpreter (/bin/bash) not the script.
  • cwd which is a symlink to the current directory of the process
  • cmdline which is a NUL separated representation of the command line

you also have a list of current file descriptors. I find /proc/*pid*/fd/255 useful in bash scripts - it's a symlink to the script itself.

ps looks at /proc/ to find info, so there may be some magic incantation of flags that shows some of these - look at ps -o

share|improve this answer


ps auxf

This gives you the hierarchy of the processes.

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.