Shell and environment

Command env

Show or run command with environment

Linux · Bash examples · commands run on the selected server

When to use env

Use env to launch a command with deliberate environment changes. This helps reproduce locale or proxy behavior, but a reduced environment can also remove configuration and authentication that a program needs.

Syntax

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

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-i
Start with an empty environment.
-u NAME
Remove the specified variable for the command to be run.
NAME=VALUE
Set the variable only for the child process.

Usage examples

Run a command with the given locale

env LC_ALL=C sort ./names.txt

Only this sorting command receives the selected deterministic locale.

Run without one variable

env -u HTTP_PROXY curl -I https://example.com

The proxy variable is removed from this process environment; other proxy variables and configuration may still apply.

Run with minimal environment

env -i PATH=/usr/bin:/bin /usr/bin/printenv PATH

A minimal environment is created with an explicit command path and only the supplied variables.

Notes and limitations

  • Without the command, env displays the environment that may contain secrets; do not publish it without checking.
  • Changes to the child process do not change the environment of the parent shell.

Common questions and troubleshooting

Does removing one proxy variable guarantee a direct connection?

No. Other environment names and application configuration may set a proxy. Inspect the client's documented configuration precedence.

Can I publish the output of env safely?

Not without review. Environment variables can contain credentials and tokens. Prefer targeted variable checks over dumping the complete environment.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man env.