LoginSignup
13
11

More than 5 years have passed since last update.

プロセスを実行した時の環境変数を知りたい(Linux)

Posted at

Linuxでプロセスを実行したときの環境変数を知りたい場合は、/proc/[pid]/environファイルで確認できます。
ただ、各項目がnullで区切られているので、catなどで表示しても見にくいです。
以下のコマンドで見やすくなります。

その1(stringsを使う)

strings /proc/[pid]/environ

stringsコマンドは、バイナリフィアルや得体のしれないファイルから文字列を拾ってくれます。
何のファイルかの見当をつけるのにも使えます。

その2(trを使う)

cat /proc/[pid]/environ | tr "\000" "\n"
13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11