Article Title: how to obtain the path of the linux Process Execution file. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
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] # All 22401
Total 0
-R -- 1 zhouys 0 Dec 11 :10 running line
-R -- 1 zhouys 0 Dec 11 cpu
Lrwxrwxrwx 1 zhouys 0 Dec 11 :10 cwd->/home/zhouys/sbs/bin
-R -------- 1 zhouys 0 Dec 11 :10 environ
Lrwxrwxrwx 1 zhouys 0 Dec 11 :10 exe->/home/zhouys/sbs/bin/cbs (deleted)
Dr-x ------ 2 zhouys 0 Dec 11 :10 fd
-R -------- 1 zhouys 0 Dec 11 11:10 maps
-Rw ------- 1 zhouys 0 Dec 11 :10 mem
-R -- 1 zhouys 0 Dec 11 :10 mounts
Lrwxrwxrwx 1 zhouys 0 Dec 11 :10 root->/
-R -- 1 zhouys 0 Dec 11 :10 stat
-R -- 1 zhouys 0 Dec 11 :10 statm
-R -- 1 zhouys 0 Dec 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
Find the application to use this service program.