Suggested day 1720–30 minutesCaution

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.

Outcome: You stop retyping long commands and start using recall tools carefully.

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

1

View history

Read-only

Shows recent commands.

Terminal
history 10
2

Repeat simple commands

Caution

Repeats the previous harmless echo command.

Terminal
echo 'safe repeat demo'
!!
3

History clearing example

Caution

Clears current shell memory history. Explanation only for most learners.

Terminal
history -c

Checkpoint

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?

Shortcuts:Alt + ← previous lessonAlt + → next lessonAlt + H home? focus search