man > env(1)

🏷️ NAME

env - run a program in a modified environment

πŸš€ Quick Reference

Use CaseCommandDescription
🧹 Run with empty environmentenv -i commandStart with no environment variables
πŸ”§ Set custom environment variablesenv NAME=VALUE commandRun command with modified environment
❌ Remove a variableenv -u NAME commandUnset a specific environment variable
πŸ“‚ Change working directoryenv -C DIR commandRun command in different directory
πŸ”— Split string for shebang#!/usr/bin/env -S perl -w -TPass multiple arguments in script shebang
🚦 Handle signalsenv --default-signal=PIPE seq inf | head -n1Reset signal handler to default
πŸ“‹ Print environmentenvDisplay current environment (no command)

πŸ”§ SYNOPSIS

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

πŸ“– DESCRIPTION

Set each NAME to VALUE in the environment and run COMMAND.

Mandatory arguments to long options are mandatory for short options too.

🧹 -i, --ignore-environment
Start with an empty environment

πŸ”Œ -0, --null
End each output line with NUL, not newline

❌ -u, --unset=NAME
Remove variable from the environment

πŸ“‚ -C, --chdir=DIR
Change working directory to DIR

βœ‚οΈ -S, --split-string=S
Process and split S into separate arguments; used to pass multiple arguments on she‑bang lines

🚫 --block-signal[=SIG]
Block delivery of SIG signal(s) to COMMAND

πŸ”„ --default-signal[=SIG]
Reset handling of SIG signal(s) to the default

🀫 --ignore-signal[=SIG]
Set handling of SIG signals(s) to do nothing

πŸ“‹ --list-signal-handling
List non‑default signal handling to stderr

🐞 -v, --debug
Print verbose information for each processing step

❓ --help
Display this help and exit

πŸ“Ÿ --version
Output version information and exit

πŸ” A mere - implies -i. If no COMMAND, print the resulting environment.

⚠️ SIG may be a signal name like PIPE, or a signal number like 13. Without SIG, all known signals are included. Multiple signals can be comma‑separated.

βš™οΈ OPTIONS

βœ‚οΈ -S/--split-string usage in scripts

The -S option allows specifying multiple parameters in a script. Running a script named 1.pl containing the following first line:

#!/usr/bin/env -S perl -w -T
...

Will execute perl -w -T 1.pl.

Without the -S parameter the script will likely fail with:

/usr/bin/env: 'perl -w -T': No such file or directory

See the full documentation for more details.

πŸ”„ --default-signal[=SIG] usage

This option allows setting a signal handler to its default action, which is not possible using the traditional shell trap command. The following example ensures that seq will be terminated by SIGPIPE no matter how this signal is being handled in the process invoking the command.

sh -c 'env --default-signal=PIPE seq inf | head -n1'

πŸ“ NOTES

POSIX's exec(2) pages says:

β€œmany existing applications wrongly assume that they start with certain signals set to the default action and/or unblocked…. Therefore, it is best not to block or ignore signals across execs without explicit reason to do so, and especially not to block signals across execs of arbitrary (not closely cooperating) programs.”

✍️ AUTHOR

Written by Richard Mlynarik, David MacKenzie, and Assaf Gordon.

πŸ› REPORTING BUGS

GNU coreutils online help: https://www.gnu.org/software/coreutils/
Report any translation bugs to https://translationproject.org/team/

©️ COPYRIGHT

Copyright Β© 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

πŸ“š SEE ALSO

sigaction(2), sigprocmask(2), signal(7)

Full documentation: https://www.gnu.org/software/coreutils/env
or available locally via: info '(coreutils) env invocation'

env(1)
🏷️ NAME πŸš€ Quick Reference πŸ”§ SYNOPSIS πŸ“– DESCRIPTION βš™οΈ OPTIONS
βœ‚οΈ -S/--split-string usage in scripts πŸ”„ --default-signal[=SIG] usage
πŸ“ NOTES ✍️ AUTHOR πŸ› REPORTING BUGS ©️ COPYRIGHT πŸ“š SEE ALSO

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-03 19:02 @216.73.216.23
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^