Chapter 14 of 17
Manage your shell environment
Understand variable scope, startup files, command lookup, and reproducibility.
The mental model.
A shell variable belongs to the current shell. export marks a variable for inheritance by child processes. Children cannot modify the parent’s environment. unset removes a variable; unalias removes an alias.
PATH is a colon-separated search list. The first matching executable wins. Putting a writable or untrusted directory first allows a malicious file to impersonate a common command. Avoid adding . to PATH.
Bash reads different startup files for login and interactive non-login shells. .bashrc commonly configures interactive shells, while a login shell reads a profile. source executes a file in the current shell, so only source files you trust.
Aliases are interactive conveniences, not portable script dependencies. Keep scripts explicit. Do not store secrets in public dotfiles, command history, or exported diagnostic reports.
Read it. Predict it. Try it.
Before running these commands, predict what each line will change or print. Launch a quest below to open the simulated terminal.
echo "$PATH"
export EDITOR=nano
echo "$EDITOR"
alias ll="ls -la"
type ll
unalias llInspect lookup paths, set a child-visible preference, then define and remove a convenience alias.
Check your understanding
Explain the why.
Put it into practice.
Complete the exercises, then try the Boss Challenge without hints. Each quest checks its own objectives. You can revisit this chapter at any time.
Make the learning stick.
Close the explanation and describe the main idea in your own words. Change a filename or input and predict the outcome. Tomorrow, repeat a quest without hints. Then apply it in a disposable real Linux environment.
Open the real-system labs →