Mission 2 of 5
History and Command Recall
Use history to recover useful commands without erasing more than intended.
Reuse previous commands, search history, and learn which history shortcuts require caution.
Mental model
Understand what is happening
The shell remembers commands.
Ctrl+R searches backwards interactively.
History expansion runs commands, so read before pressing Enter.
Guided lab
Work through the mission
View history
Shows recent commands.
history 10Repeat simple commands
Repeats the previous harmless echo command.
echo 'safe repeat demo'
!!History clearing example
Clears current shell memory history. Explanation only for most learners.
history -cCheckpoint
Verify the mission
A useful prior command can be found without clearing history.
Try it yourself
One step without a recipe
Run three echo commands, then use history 5. Try Ctrl+R and abort with Ctrl+G if you do not want to run anything.
Need a hint?
Ctrl+R is your best friend for long commands. Start typing a distinctive piece of the command you want. When it appears, press Enter. No retyping, no arrow-key marathons.
Explain it back
Before you move on
- What shortcut searches history?
- Why is !number a caution feature?