Productive terminal habits—history, completion, job control, and readable prompts—speed up every track. This lesson mirrors what you will do throughout Bash: read, copy, run locally, observe output.
Recommended workflow
- Read the concept section before typing commands.
- Copy one block at a time into your terminal.
- If output differs, check your OS (macOS vs Linux flags).
- Fix errors from the first message—Bash often stops at the first failing command in a script with
set -e.
Essential shortcuts
# History: Up/Down arrows, Ctrl+R reverse search
# Clear screen: Ctrl+L
# Stop program: Ctrl+C
# End of file (close stdin): Ctrl+D
history | tail -5Practice Ctrl+R to find past git commands while learning Git.
Practice folder
mkdir -p ~/bash-practice
cd ~/bash-practice
pwd
echo "practice ready" > notes.txt
cat notes.txtKeep exercises in a dedicated folder so you never confuse homework files with real projects.
Important interview questions and answers
- Q: How do you stop a runaway command?
A: Press Ctrl+C—sends SIGINT to the foreground process. - Q: Why a practice directory?
A: Isolates experiments and makes cleanup easy without touching system paths.
Self-check
- What keyboard shortcut searches command history interactively?
- What command prints your current working directory?
Challenge
Practice in your terminal
- Create
~/bash-practiceandcdinto it. - Copy the
mkdir/pwdblock from the lesson. - Run
history | tailand retry a command withCtrl+R.
Done when: your practice folder exists and you recovered a command from history.
Interview prep
- Ctrl+C effect?
Sends SIGINT to stop the foreground process.
- Why a practice directory?
Isolates experiments and prevents accidental changes to real projects.