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:
- [root@Cluster1 proc]# ll 22401
- total 0
- -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 cmdline
- -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 cpu
- lrwxrwxrwx 1 zhouys zhouys 0 Dec 11 11:10 cwd -> /home/zhouys/sbs/bin
- -r-------- 1 zhouys zhouys 0 Dec 11 11:10 environ
- lrwxrwxrwx 1 zhouys zhouys 0 Dec 11 11:10 exe -> /home/zhouys/sbs/bin/cbs (deleted)
- dr-x------ 2 zhouys zhouys 0 Dec 11 11:10 fd
- -r-------- 1 zhouys zhouys 0 Dec 11 11:10 maps
- -rw------- 1 zhouys zhouys 0 Dec 11 11:10 mem
- -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 mounts
- lrwxrwxrwx 1 zhouys zhouys 0 Dec 11 11:10 root -> /
- -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 stat
- -r--r--r-- 1 zhouys zhouys 0 Dec 11 11:10 statm
- -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.