When to use env
Use env to launch a command with deliberate environment changes. This helps reproduce locale or proxy behaviour, 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
Usage examples
Run a command with the given locale
env LC_ALL=C sort ./names.txtOnly this sorting command receives the selected deterministic locale.
Run without one variable
env -u HTTP_PROXY curl -I https://example.comThe 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 PATHA 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.