Skip to main content

env command

Detailed Explanation

The env command is used to either display the current environment variables or to run a specified command in a modified environment without permanently changing the environment variables of the current shell.

Basic Syntax

env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]

Common Flags/Options

OptionDescription
-i, --ignore-environmentStart with an empty environment.
-u <name>, --unset=<name>Remove variable <name> from the environment.

Real-world Examples

Display all current environment variables:

env

Run a script with a specific environment variable set temporarily:

env MY_VAR="testing" ./my_script.sh

Run a command in a completely clean/empty environment:

env -i bash --noprofile --norc