Glossary

env

env has two jobs: print the current environment, or run a command with a modified environment. It is also the conventional target of #!/usr/bin/env shebangs, which find an interpreter on $PATH rather than hard-coding its location.

env                              # print all environment variables
env -i ./script.sh               # run with an empty environment
env FOO=bar ./prog               # run with FOO set
env -u HOME ./prog               # run with HOME unset
#!/usr/bin/env python3
print("Hello")

/usr/bin/env python3 works on any system where python3 is on the $PATH, whereas #!/usr/bin/python3 hard-codes a path that is wrong on BSDs, Homebrew, and Nix.

Related terms: export, Shell, Environment Variable

Discussed in:

This site is currently in Beta. Contact: Chris Paton

Textbook of AI · Textbook of Usability · Textbook of Digital Health

Auckland Maths and Science Tutoring

AI tools used: Claude (research, coding, text), ChatGPT (diagrams, images), Grammarly (editing).