2

If a process is running how can I find its disk path using command on terminal ? In my case a process synergy is running and I want to locate it on disk

ps -ef 

shows the path of other processes but not this one.

  • can you clarify what exactly you need ? you want the location of the executable file ? – Sergiy Kolodyazhnyy Apr 19 '15 at 4:25
2

If you know the PID of the process, you can examine the contents of its /proc entry, in particular, the exe file:

$ ls -l /proc/$$/exe   
lrwxrwxrwx 1 muru muru 0 Apr 17 19:41 /proc/13339/exe -> /usr/bin/zsh
$ sudo ls -l /proc/1/exe
lrwxrwxrwx 1 root root 0 Apr 17 17:40 /proc/1/exe -> /usr/lib/systemd/systemd

IIRC what ps -ef reports are the arguments of the process (starting from argv[0], which is the command called as is), but a process is free to rewrite its arguments. Hence ps -ef may not be accurate.

1

You have written:

If a process is running how can I find its disk path using command on terminal ? In my case a process synergy is running and I want to locate it on disk

Open a terminal and run the following commands, depending on how you want to proceed. I use synergy because you mentioned it:

  • If you really want to use ps, then you can use this command.

    ps -o command= -p "$(ps -C synergy -o pid=)" | xargs which
    
  • If you want to know just where the executable is located, then use this command

    which synergy
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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