Environment Variables and Shell Startup
PRIMARY CONCEPT - Core mastery required for cluster advancement
Concept Cluster Navigation
Cluster 03: Environment Automation
- 06-Environment Variables and Shell Startup (PRIMARY - you are here)
- 07-Dotfiles and Reproducible Setup (SUPPORTING)
- 08-Workflow Integration, Remote Work, and Automation (SUPPORTING)
What This Concept Is
Your shell session starts with configuration. Environment variables, shell variables, startup files, aliases, and functions define how commands are found and how tools behave.
Why It Matters Here
Many environment problems are really startup-file problems:
- command not found
- wrong Python or Node version
- aliases not loading
- prompt changes missing
- tools behaving differently across sessions
If you understand shell startup and variables, these problems become diagnosable instead of mysterious.
Concrete Example
A command is not found. Inspect command -v command-name and type command-name before changing anything. A directory in PATH helps the shell discover executables; it does not make arbitrary files executable or prove which configuration loaded.
For the core exercise, use the isolated configuration lab. It demonstrates export, sourcing and removal with a small fixture and avoids changing your real startup files.
Common Confusion / Misconception
Common beginner confusion:
- mixing shell variables with environment variables
- editing the wrong startup file
- changing a file but forgetting to reload it
- not understanding that child processes inherit environment variables
How To Use It
Inspect only the variables needed for the question; a full environment dump can include credentials. Practice export LAUNCHPAD_LABEL=practice, a child process reading that variable, and unset LAUNCHPAD_LABEL in a disposable child shell.
Identify your interpreter before choosing a startup file. Interactive non-login Bash normally reads ~/.bashrc; login Bash reads a profile file. Interactive zsh uses .zshrc in its configured startup directory. source ~/.bashrc is not a universal instruction for every terminal. $SHELL may name the configured login shell rather than the currently running interpreter. See GNU Bash startup rules and your installed shell manual.
Sourcing executes a file's commands in the current shell. Deleting a line from the file does not reverse a previously executed alias or export. Use explicit removal or a fresh isolated session and verify the result.
Check Yourself
- Can you explain what
PATHdoes in one sentence? - Do you know how to tell whether a command is an alias, builtin, or executable?
- If a config change does not seem to apply, do you know what to inspect first?
Mini Drill or Application
Complete the linked configuration lab: predict the exported child value, load the fixture, observe the alias, remove its definition from the file, test live state and rebuild in a fresh child. Separately identify how your real shell starts. Personal customization is optional; preserve the same demonstrated concepts if you keep the exercise isolated.
Read this only if stuck
- Start with Reference and Selective Reading for the curated shell, editor, and environment sources.
- If you need a second explanation, skim Missing Semester and then retry the commands from this page.
- Prefer one concrete terminal action over more passive reading.
Video and Lecture References
- Primary lecture: Missing Semester 2026 - Command-line Environment
- Local source: command-line-environment.md
Depth Path
Professional Integration
Environment control is one of the clearest markers of engineering maturity. The ability to explain PATH, exported variables, and startup behavior is what separates "I install tools" from "I manage a working development environment."
Cluster Integration Check
- You can explain
PATH - You can export a variable and verify it
- You know how to reload your shell configuration
- You can diagnose why a command is or is not being found
Ready to advance: Continue to Dotfiles and Reproducible Setup.