env
プロセスとシステム
書き方
env [VAR=value] [command]環境変数をすべて表示するか、変数を足してコマンドを一つ動かします。その変数はその一回の実行にだけ付き、シェルには何も残りません。
よく使うオプション
| オプション | 意味 |
|---|---|
| env | With no arguments, print the whole environment. |
| VAR=value <command> | Run the command with that variable added, for this run only. |
| -i | Start from an empty environment, inheriting nothing. |
| -u <VAR> | Unset one variable for the child process. |
例
env | sort | grep -i proxyFind the proxy variables that are breaking a download.
env NODE_ENV=production node app.jsSet a variable for one run without touching your shell.
env -i bash --noprofile --norcA shell with nothing inherited, for reproducing a cron failure.
何が動いていて何が資源を食っているかを見ます。止める前に何なのかを確かめるのが順番です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. env は何をしますか。
環境変数をすべて表示するか、変数を足してコマンドを一つ動かします。その変数はその一回の実行にだけ付き、シェルには何も残りません。
Q. どう打ちますか。
env [VAR=value] [command] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは4個です。全部は man env にあります。このコマンドはプロセスとシステムの仲間です。
関連するコマンド
man ページ: man env