Linux5h estimated

Environment & Configuration

Difficulty
Importance

The problem

Programs need machine- and user-specific settings (where to find executables, which mode to run in, secret credentials) without hardcoding them into source code — environment variables and configuration files give every process a way to receive that context from outside itself.

Why now

Variables and state already established that a name can be bound to a value that changes; an environment variable is that exact idea, scoped to a whole process (or shell session) instead of a single function, letting configuration flow from the shell into every program it launches.

Mental model

An environment variable is a global variable for a process and everything it spawns — set it in the shell, and every child process inherits a copy. PATH is the clearest example: a list of directories the shell searches, in order, whenever you type a command name instead of a full path.

Requires

Unlocks

Used in

Projects

  • Inspect your PATH variable, then deliberately add a directory to it and confirm a script in that directory becomes runnable by name
  • Move a hardcoded API key out of a script and into an environment variable, loaded via a .env file

Examples

  • Typing node runs whichever node executable is found first by searching each directory in PATH, in order
  • A Node.js app reading process.env.DATABASE_URL lets the same code run against different databases in development and production

Resources

Mastery checklist