In order to see the path of the running process 25014 I do on Linux the following:

  ls -l /proc/25014/exe


 lrwxrwxrwx 1 root root 0 Mar  9 16:35 /proc/25014/exe -> /etc/syscconfig

In case we have Solaris OS. What the same concept on Solaris? In Solaris we not have the exe file.


I'M THE AUTHOR AND THIS ANSWER IS INCORRECT AND SHOULD BE DELETED (cannot delete as it is the accepted answer). As pointed out in comments below it will return the process' working directory, aka current directory. Unless the process itself has changed its working directory then it will be the directory from which the process was started, not the directory of the executable. Bottom line: this answer is incorrect in the context of the question.

Here's one way of doing it.

In Solaris you would use the pargs -ae <pid> command for this.

The line that says argv[0]: will tell you what executable is running. This is however not enough as you do not know the current directory of that process when it was started so if arg0 is not fully qualified then you don't have the full path to the running application. Fear not. Look further down in the output of the above command and within the output of the process' environment variables look for PWD. Combine the two and you have the full path to the executable.

Here's some sample output from a pargs -ae command:

8200:   ./sshd
argv[0]: ./sshd

envp[0]: LANG=C
envp[1]: LC_ALL=
envp[2]: LC_COLLATE=
envp[3]: LC_CTYPE=
envp[4]: LC_MESSAGES=
envp[5]: LC_MONETARY=
envp[6]: LC_NUMERIC=
envp[7]: LC_TIME=
envp[8]: PATH=/usr/sbin:/usr/bin
envp[9]: PWD=/usr/lib/ssh
envp[10]: SHLVL=2
envp[11]: SMF_FMRI=svc:/network/ssh:default
envp[12]: SMF_METHOD=start
envp[13]: SMF_RESTARTER=svc:/system/svc/restarter:default
envp[14]: SMF_ZONENAME=myhost1
envp[15]: TZ=localtime
envp[16]: A__z="*SHLVL
  • This gave me the directory from which I was in when I started the process, not the absolute path to its executable. The other answer is correct: ls -l /proc/<pid>/path/a.out – codenaugh Sep 26 '17 at 20:52
  • 1
    @CommanderCody. Ouch. You are absolutely correct. I cannot delete as this answer was accepted, but I can flag it. Will do. – peterh Sep 27 '17 at 6:04
  • To be fair, the question isn't entirely clear whether the person wants what you gave as an answer or what the other person wants as an answer. I assume the other answer is truly the correct one, but this one was selected as the correct answer so it's all a bit confusing. You may just want to simply explain the differences between the 2 answers and leave out the "extra stuff" about whether yours is wrong or not and should be deleted. I think your answer provides some value. – codenaugh Sep 29 '17 at 4:33

The most direct Solaris equivalent is /proc/<pid>/path/a.out For example:

% ls -l /proc/$$/path/a.out
lrwxrwxrwx   1 alanc    staff          0 Mar 13 21:16 /proc/2892/path/a.out -> /usr/bin/tcsh*

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.