Get your API key

Lesson 4 of 5

Environment variables and PATH

Named settings your terminal hands to programs, where API keys live, and how to fix "command not found".

8 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson you will read and set environment variables, know where tools like Claude Code look for settings, and fix the "command not found" error yourself.

You need: a terminal (lesson 2) · Time: 8 minutes

  1. An environment variable is a named setting that your terminal hands to every program it starts. It is a NAME with a value, like HOME = /home/asha.

    Think of the notice board at a chai stall: "Today's milk supplier: Sharma Dairy". Every worker who comes in reads the board instead of asking. Programs do the same: instead of asking you each time, they read the environment.

    You'll meet three kinds:

    • System ones that are always there: your home folder, your user name, and PATH (the list of folders where programs live; more below).
    • Tool settings: a coding agent may read its server address and key from variables. For example, the Claude Code guide uses ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to point Claude Code at AllModelAPI.
    • Project settings: your app reads its secrets from variables, usually loaded from a .env file (Keep secrets secret).
    Why?

    When an install guide says "set this variable" or the AI says "the key is undefined", it is talking about this notice board. Once you know where it is, these messages make sense.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Read a variable
  2. Set one for this window only
  3. Make it permanent
  4. PATH and "command not found"
  5. Recap