Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 15
    @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
    Commented Feb 18, 2016 at 9:05
  • An obvious way this answer is wrong: on my machine I run processes with different JDK versions and some 32bits/64bits. If I want to identify the correct jstack/jmap version for the process the answer above will not work while the accepted answer will. Commented Dec 7, 2016 at 7:36
  • 1
    @Kokizzu This only answers the question, "What is the current working directory of the process $pid?" The edited post still doesn't answer the question. which merely tells "If the command is on the path, then what is it?" Commented Jun 5, 2018 at 11:42
  • pwdx return me the absolute path of the exectuable program of the process depending on pid on redhat x64 6.3.
    – Nick Dong
    Commented Dec 30, 2018 at 6:05
  • This does not answer the question at all. Commented Dec 30, 2020 at 14:53