Mission 15 of 30 · Milestone
Environment Variables
Inspect and temporarily change the environment seen by a command.
Understand the configuration values your shell and programs share, including PATH.
Practice inside
~/linux-practice. Check your setup before you begin.
Prerequisite: Process Management
.
What you’ll practice
- Read environment variables
- Export temporary variables
- Inspect command locations
The mental model
- Environment variables are KEY=VALUE pairs.
- Exported variables are visible to child processes.
- PATH tells the shell where to find commands.
Try it in your terminal
Inspect variables
Read-only system viewReads common environment variables.
Run from ~/linux-practice
printenv | head -20
echo $HOME
echo $USER
echo $SHELL
echo $PATH Export a temporary variable
Safe in practice folderCreates and removes a temporary variable.
Run from ~/linux-practice
export MY_NAME='Linux Learner'
echo $MY_NAME
bash -c 'echo Child sees: $MY_NAME'
unset MY_NAME Practice PATH safely
Safe in practice folderTemporarily adds your practice bin folder to PATH.
Run from ~/linux-practice
mkdir -p ~/linux-practice/bin
export PATH="$HOME/linux-practice/bin:$PATH"
which ls
whereis bash
type cd Find the command your shell will run
Read-only system viewcommand -v is the portable way to find a command or shell builtin. command -V gives a fuller explanation, while env lists exported variables for the current process.
Run from ~/linux-practice
command -v ls
command -v cd
command -V cd
env | sort | head -20 Put it into practice
- Create MY_FAVORITE_COLOR, echo it, then unset it.
Check your result
A child command sees the exported value and a new shell starts clean.
Milestone challenge
Locate a practice file, inspect its permissions and owner, start and stop only your own practice process, and capture the relevant environment facts in a report.
Common mistakes
- You set `MY_VAR='hello'` in one terminal, open a new terminal window, and type `echo $MY_VAR`. It's empty. That's because variables without `export` only live in the current shell. Child processes — including new terminals — can't see them. Use `export MY_VAR='hello'` when you need other processes to inherit the value.
- You find a guide that says 'add this line to your .bashrc' and you paste it in immediately. Test the change first with a temporary `export` in your current session. Make sure it actually does what you expect. Only after it works should you write it permanently into a config file. Permanent changes are harder to undo.
Check your understanding
Explain these in your own words. If you’re unsure, revisit the examples before moving on.
- What does PATH control?
- What does export do?
Your practice, your pace
Loading saved progress…