Back to the command reference

env

ShellFundamentals In simulator In real Linux

Show the environment or run a command in a modified one

Name: env = environment

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

With no arguments env prints the environment. It can also run a command in a modified environment, e.g. env LANG=C sort file, affecting only that command.

The shebang #!/usr/bin/env bash relies on env to find the interpreter in PATH.

Syntax

env [NAME=VALUE]... [COMMAND]

Common options

NAME=VALUESet variables, then run the command, e.g. env LANG=C sort f
-i / --ignore-environmentStart with an empty environment
-u / --unset NAMERemove a variable from the environment
-C / --chdir DIRChange to DIR before running the command

Examples

Related