1 パウダー
構文: pwdx pid
[root@localhost prometheus-2.42.0.linux-amd64]# ps -ef | grep prometheus
root 13820 1361 0 10:56 pts/0 00:00:00 ./prometheus
root 13839 1361 0 10:57 pts/0 00:00:00 grep --color=auto prometheus
[root@localhost prometheus-2.42.0.linux-amd64]# pwdx 13820
13820: /home/qingfeng/soft/prometheus-2.42.0.linux-amd64
2 ls -l /proc/${pid}
Linux がプロセスを開始すると、システムは /proc の下に PID に基づいた名前のフォルダーを作成します。このフォルダーの下には、絶対パスを記録する exe という名前のファイルを含む、プロセスに関する情報が含まれます。ll または ls –l コマンド見るために。
- cwd シンボリック リンクは、プロセスの実行ディレクトリです。
- exe シンボリック リンクは、プログラムを実行するための絶対パスです。
- cmdline は、プログラムの実行時に入力されるコマンド ライン コマンドです。
- environ は、プロセスの実行時に環境変数を記録します。
- fd ディレクトリは、プロセスによって開かれたファイルまたは使用されたファイルへのシンボリック リンクです。
grep と組み合わせて使用できます。たとえば
ls -l /proc/${pid} | grep cwd
ls -l /proc/proc/${pid} | grep exe
、プロセスが 13820 であることがすでにわかっているので、
[root@localhost prometheus-2.42.0.linux-amd64]# ls -l /proc/13820
总用量 0
dr-xr-xr-x. 2 root root 0 3月 7 11:04 attr
-rw-r--r--. 1 root root 0 3月 7 11:04 autogroup
-r--------. 1 root root 0 3月 7 11:04 auxv
-r--r--r--. 1 root root 0 3月 7 11:04 cgroup
--w-------. 1 root root 0 3月 7 11:04 clear_refs
-r--r--r--. 1 root root 0 3月 7 10:56 cmdline
-rw-r--r--. 1 root root 0 3月 7 11:04 comm
-rw-r--r--. 1 root root 0 3月 7 11:04 coredump_filter
-r--r--r--. 1 root root 0 3月 7 11:04 cpuset
lrwxrwxrwx. 1 root root 0 3月 7 10:58 cwd -> /home/qingfeng/soft/prometheus-2.42.0.linux-amd64
-r--------. 1 root root 0 3月 7 11:04 environ
lrwxrwxrwx. 1 root root 0 3月 7 10:56 exe -> /home/qingfeng/soft/prometheus-2.42.0.linux-amd64/prometheus
dr-x------. 2 root root 0 3月 7 10:56 fd
dr-x------. 2 root root 0 3月 7 11:00 fdinfo
-rw-r--r--. 1 root root 0 3月 7 11:04 gid_map
-r--------. 1 root root 0 3月 7 11:04 io
-r--r--r--. 1 root root 0 3月 7 11:04 latency
-r--r--r--. 1 root root 0 3月 7 10:56 limits
-rw-r--r--. 1 root root 0 3月 7 11:04 loginuid
-rw-r--r--. 1 root root 0 3月 7 11:04 make-it-fail
dr-x------. 2 root root 0 3月 7 11:04 map_files
-r--r--r--. 1 root root 0 3月 7 11:00 maps
-rw-------. 1 root root 0 3月 7 11:04 mem
-r--r--r--. 1 root root 0 3月 7 11:04 mountinfo
-r--r--r--. 1 root root 0 3月 7 11:04 mounts
-r--------. 1 root root 0 3月 7 11:04 mountstats
dr-xr-xr-x. 5 root root 0 3月 7 11:04 net
dr-x--x--x. 2 root root 0 3月 7 11:04 ns
-r--r--r--. 1 root root 0 3月 7 11:04 numa_maps
-rw-r--r--. 1 root root 0 3月 7 11:04 oom_adj
-r--r--r--. 1 root root 0 3月 7 11:04 oom_score
-rw-r--r--. 1 root root 0 3月 7 11:04 oom_score_adj
-r--r--r--. 1 root root 0 3月 7 11:04 pagemap
-r--------. 1 root root 0 3月 7 11:04 patch_state
-r--r--r--. 1 root root 0 3月 7 11:04 personality
-rw-r--r--. 1 root root 0 3月 7 11:04 projid_map
lrwxrwxrwx. 1 root root 0 3月 7 11:00 root -> /
-rw-r--r--. 1 root root 0 3月 7 11:04 sched
-r--r--r--. 1 root root 0 3月 7 11:04 schedstat
-r--r--r--. 1 root root 0 3月 7 11:04 sessionid
-rw-r--r--. 1 root root 0 3月 7 11:04 setgroups
-r--r--r--. 1 root root 0 3月 7 11:04 smaps
-r--r--r--. 1 root root 0 3月 7 11:04 stack
-r--r--r--. 1 root root 0 3月 7 10:56 stat
-r--r--r--. 1 root root 0 3月 7 11:04 statm
-r--r--r--. 1 root root 0 3月 7 10:56 status
-r--r--r--. 1 root root 0 3月 7 11:04 syscall
dr-xr-xr-x. 10 root root 0 3月 7 11:00 task
-r--r--r--. 1 root root 0 3月 7 11:04 timers
-rw-r--r--. 1 root root 0 3月 7 11:04 uid_map
-r--r--r--. 1 root root 0 3月 7 11:04 wchan