A Brief Introduction to how to obtain the file path of a Linux Process

Source: Internet
Author: User

Where can I find the file path of a Linux Process? Sometimes it will make the Linux System Administrator worry about it. Here is a simple case. I believe it will benefit many administrators, it helps you easily obtain the desired Linux Process file path and complete the specified task.

Enter the/proc directory

Ps: view all processes that match./cmd and find the corresponding process number.

Run ll command: ll process number

An example is shown as follows:

 
 
  1. [root@Cluster1 proc]# ll 22401  
  2. total 0  
  3. -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 cmdline  
  4. -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 cpu  
  5. lrwxrwxrwx 1 zhouys zhouys 0 Dec 11 11:10 cwd -> /home/zhouys/sbs/bin  
  6. -r-------- 1 zhouys zhouys 0 Dec 11 11:10 environ  
  7. lrwxrwxrwx 1 zhouys zhouys 0 Dec 11 11:10 exe -> /home/zhouys/sbs/bin/cbs (deleted)  
  8. dr-x------ 2 zhouys zhouys 0 Dec 11 11:10 fd  
  9. -r-------- 1 zhouys zhouys 0 Dec 11 11:10 maps  
  10. -rw------- 1 zhouys zhouys 0 Dec 11 11:10 mem  
  11. -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 mounts  
  12. lrwxrwxrwx 1 zhouys zhouys 0 Dec 11 11:10 root -> /  
  13. -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 stat  
  14. -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 statm  
  15. -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 status 

The files under the process number directory in the/proc file system mirror the current running information of the process,

We can see that:

The cwd symbolic link is the running directory of process 22401;

The exe symbolic connection is the absolute path of the execution program;

Cmdline is the command line command entered when the program is running. In this example:./cbs

The cpu records the cpu on which the process may run. The virtual cpu information is displayed.

Environ records the environment variables when the process is running.

The fd directory is the symbolic connection of the files opened or used by the process.

...

You can directly access the process running directory through cwd. by viewing the relevant information, you can locate the port number corresponding to this directory and locate the application to use this service program. In this way, the path of the Linux Process file is obtained.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.