# Environment Variable

> A named value that the shell gives to each program it starts.

**Field:** Infrastructure  
**Category:** Linux & the Command Line  
**Also known as:** Env Var, Environment Variables, ENV

## Think of it like

Think of it like a sticky note on the fridge. Anyone in the house can read it.

## Definition

An environment variable is a named value that the shell hands to every program it starts. Programs read it to learn settings, like which folder is home or which key to use. You set one with a line like export NAME=Emma. Its name is usually written in capital letters. Secrets such as passwords are often passed this way, so they never sit in the code.

## 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.

## Example code

```console
$ export NAME=Emma
$ echo "Hi $NAME"
Hi Emma
```

Set a value called NAME, then read it back.

## Why it matters

It keeps settings and secrets out of the code. The same app can then run anywhere.

## Common mistake

Setting it in one terminal and expecting another to see it. Each shell has its own copy.

## Three principles

- **Named value.** Usually in capitals.
- **Handed down.** Every program it starts sees it.
- **Keeps secrets out.** Not written in the code.

## Related terms

- [Shell](https://learn.benibix.com/term/infrastructure/shell)
- [.env File](https://learn.benibix.com/term/development/env-file)
- [Configuration File](https://learn.benibix.com/term/development/config-file)
- [Terminal](https://learn.benibix.com/term/infrastructure/terminal)

## Taught in

- [.env Files and package.json](https://learn.benibix.com/learn/development-formats/env-files-and-package-json): File Formats, 6/11
- [Environment Variables](https://learn.benibix.com/learn/infrastructure-linux/environment-variables): Linux CLI, 3/10

---

Source: https://learn.benibix.com/term/infrastructure/environment-variable
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
