⌨️Environment Variable
Also known as Env Var, Environment Variables, ENV
A named value that the shell gives to each program it starts.
Think of it like
Think of it like a sticky note on the fridge. Anyone in the house can read it.
Example
Jack's app reads its database password from an environment variable. The code stays the same on Jack's laptop and on the server.
Why it matters
It keeps settings and secrets out of the code. The same app can then run anywhere.
Definition
Example code
console
$ export NAME=Emma
$ echo "Hi $NAME"
Hi EmmaCommon mistake
Key takeaways
- 1Named value. Usually in capitals.
- 2Handed down. Every program it starts sees it.
- 3Keeps secrets out. Not written in the code.