Stack Exchange network consists of 175 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Detailed answers to any questions you might have
Discuss the workings and policies of this site
Learn more about hiring developers or posting ads with us
Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:
The best answers are voted up and rise to the top
How can I know the absolute path of a running process?
If I have multiple copies of the same application on the disk, and only one is running, as I can see withps, how can I know theabsolutepath to distinguish it from the others?
% ps -auxwe grep 24466 root 24466 0.0 0.0 1476 280 ? S 2009 0:00 supervise sshd % sudo ls -l /proc/24466/exe lrwxrwxrwx 1 root root 0 Feb 1 18:05 /proc/24466/exe –
In my system (ubuntu 14.04) you do not have to be superuser to run the
ls: cannot read symbolic link proc28783exe: Permission denied
command, its about accessing the process info of a process not belonging to you. On my box, about 97% of all processes listed in /proc are root processes, and the others are distributed over 11 different users.
This gives you the current working directory of the pid, not its absolute path.
Usually thewhichcommand will tell you which is being invoked from the shell:
@Kokizzu No, it doesnt because it doesnt 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 its been taken from, which doesnt 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.
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.
@Kokizzu This only answers the question, What is the current working directory of the process
? The edited post still doesnt answer the question.
merely tells If the command is on the path, then what is it?
return me the absolute path of the exectuable program of the process depending on pid on redhat x64 6.3.
didnt work for a specific service, it just provide the relative path
Helped me identify a process via the command it was started with.
does not show ALL full qualified paths on my linux: root 24466 0.0 0.0 1476 280 ? S 2009 0:00 supervise sshd for example
This is more accurate than the other answers… maybe not as useful, but more the right answer. Upvoted.
The quick answer is to usepswith options or the/procfilesystem info. That willusuallywork, but is not guaranteed. In general, there is no definite, guaranteed answer. For instance, what if the executing file is deleted during execution, so that there is no path to the file?
Seethe Unix FAQfor a little more detail, particularly questions 4.3 and 4.4.
Why does everyone expect you to know the PID? Heres the human-friendly way:
lsof is an option. You can try something like below:
This will list all the files opened by the process including the executables actual location. It is then possible to add a few more awk, cut, grep etc. to find out the information that you are looking for.
As an example, I executed the following commands to identify where my java process came from:
Unicorn Meta Zoo 3: How do we grade questions?
Why doesnt Adrian Toomes give up Spider-Mans identity?
Why would future John risk sending back a T-800 to save his younger self?
How to handle self harm scars on the arm in work environment?
Were Alexander the Great and Hephaestion lovers?
Should I give professor gift at the beginning of my PhD?
How can I get an unreasonable manager to approve time off?
Why didnt Voldemort recognize that Dumbledore was affected by his curse?
Is it expected that a reader will skip parts of what you write?
How can this tool find out registered domains from an IP?
Longest bridge/tunnel that can be cycled over/through?
Someone whose aspirations exceed abilities or means
How to hide rifle during medieval town entrance inspection?
Alternate way of computing the probability of being dealt a 13 card hand with 3 kings given that you have been dealt 2 kings
How can I make some of my chapters come to life?
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo 2019 Stack Exchange Inc; user contributions licensed undercc by-sa 3.0withattribution required.rev2019.6.5.33891