Mission 5 of 5
Environment Variables
Inspect and temporarily change the environment seen by a command.
Understand the configuration values your shell and programs share, including PATH.
Mental model
Understand what is happening
Environment variables are KEY=VALUE pairs.
Exported variables are visible to child processes.
PATH tells the shell where to find commands.
Guided lab
Work through the mission
Inspect variables
Reads common environment variables.
printenv | head -20
echo $HOME
echo $USER
echo $SHELL
echo $PATHExport a temporary variable
Creates and removes a temporary variable.
export MY_NAME='Linux Learner'
echo $MY_NAME
bash -c 'echo Child sees: $MY_NAME'
unset MY_NAMEPractice PATH safely
Temporarily adds your practice bin folder to PATH.
mkdir -p ~/linux-practice/bin
export PATH="$HOME/linux-practice/bin:$PATH"
which ls
whereis bash
type cdFind the command your shell will run
command -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.
command -v ls
command -v cd
command -V cd
env | sort | head -20Checkpoint
Verify the mission
A child command sees the exported value and a new shell starts clean.
Try it yourself
One step without a recipe
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.
Need a hint?
Your PATH is the list of folders your shell searches when you type a command. When "command not found" appears, the command isn't in any of those folders. Check with `echo $PATH`. If you need to add a folder, test it temporarily with `export PATH="/new/folder:$PATH"` before writing it into your shell config file.
Explain it back
Before you move on
- What does PATH control?
- What does export do?