Find the corresponding process and directory by PID in Linux

Sometimes through the top command, you can see that some processes occupy a relatively large amount of memory, but top cannot directly view the process name and the directory where the process is located. So we can locate by the following method.

Get PID

First, you need to know the PID number, which can be obtained through the top command.
  insert image description here
 Then we can use ps to see the following general information (personally, the information from ps is messy and not very convenient to find)

ps -aux |grep -v grep|grep 28990

find process directory

Through the above information, we can also find out that this is a java process. In the /opt/sonatype/nexus/bin/nexus directory, there are of course other simpler and more direct methods. After knowing the PID, you can directly enter /proc
/ 28990
insert image description here
  This can be seen intuitively.

Guess you like

Origin blog.csdn.net/qq_27566167/article/details/128215220