Lion Cipher Lab

Environment variables and the PATH

Why it matters

Every time you type a command name, something has to decide which of the thousands of programs on your machine actually runs — and that decision is made by an environment variable called PATH. Environment variables are the invisible configuration layer under the entire command line: they tell programs where your home directory is, which language and editor you prefer, where to find libraries, and — crucially — which directories to search for the very tool you just asked for. Learn them and a hundred confusing errors ('command not found' even though it IS installed; a script that works in one…

What you'll learn

Steps in this lab

  1. The mental model: what an environment variable actually is
  2. Open a terminal and view your environment
  3. Set, export, and unset — and prove a child inherits
  4. PATH: how the shell finds the program you asked for
  5. Make it persist — and know login vs interactive shells
  6. SECURITY: stage a PATH hijack (safely), then clean it up
  7. SECURITY: library hijacks (LD_PRELOAD) and why secrets don't belong in env
  8. Reflection: read it, control it, distrust it

Open the full interactive lab →