env
A command that prints the environment, or runs another program with a changed environment or found through PATH.
In more detail
With no arguments it lists every environment variable as name=value. In a shebang line such as #!/usr/bin/env python3 it searches PATH for the interpreter, so the script works wherever that interpreter is installed. env -i cmd runs a command with an empty environment.
Examples
env | sort#!/usr/bin/env bashRelated terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- shebang — The first line of a script, starting with #!, that names the program the operating system should use to run it.
- PATH — An environment variable holding a list of folders the shell searches, in order, to find the program for a command you type.
Taught in
- What A Shell Is, And What Bash Is — Bash Scripting & Command Line Automation
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Moving Around: pwd, ls, cd And Paths — Bash Scripting & Command Line Automation
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- Help, History, Completion And Aliases — Bash Scripting & Command Line Automation
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- Single Quotes, Double Quotes, Backslash — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- The Field Separator, And Reading Lines Safely — Bash Scripting & Command Line Automation
- Arrays, And Why Dollar At Is Not Dollar Star — Bash Scripting & Command Line Automation
- Standard Input, Output And Error — Bash Scripting & Command Line Automation
- Redirection: Truncate, Append, Both Streams — Bash Scripting & Command Line Automation
- Pipelines, tee And Process Substitution — Bash Scripting & Command Line Automation
- Finding Lines: grep And Regular Expressions — Bash Scripting & Command Line Automation
- Reshaping Text: cut, sort, uniq, tr, sed, awk — Bash Scripting & Command Line Automation
- Shell Variables, The Environment And export — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation
- Shebangs, Permissions And Three Ways To Run — Bash Scripting & Command Line Automation
- Exit Codes, And What Success Means — Bash Scripting & Command Line Automation
- Conditionals: test, Brackets, Double Brackets, case — Bash Scripting & Command Line Automation
- Loops: for, while, until, break, continue — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- Functions, local And declare — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- Option Parsing With getopts — Bash Scripting & Command Line Automation
- set -e, set -u And pipefail: Promises And Traps — Bash Scripting & Command Line Automation
- trap, Cleanup And Temporary Files — Bash Scripting & Command Line Automation
- Debugging: set -x, bash -n And Reading The Error — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- eval, And What To Use Instead — Bash Scripting & Command Line Automation
- Processes, Jobs And Signals — Bash Scripting & Command Line Automation
- Permissions And Ownership — Bash Scripting & Command Line Automation
- find And xargs — Bash Scripting & Command Line Automation
- Archives, Transfers And The Network — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- Shipping: scripts, entry points and git — Hands-on Python: Complete Video Course & Book
- Git For Admins: Who Changed That, And How To Undo It — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Environment Profiles: Which File Does This Shell Read? — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Variables, The PATH And The History — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep