Click the virtual machine below to start practicing
- Setting up virtual machine…
- Preparing lab files…
- Starting terminal services…
This lab machine has stopped
Your progress through the guide is saved. Start a fresh machine to keep practicing.
Click the virtual machine below to start practicing
Your progress through the guide is saved. Start a fresh machine to keep practicing.
Bash remembers the commands you run. history shows them, and a few shortcuts let you run them again without retyping.
This lab is the hands-on companion to the history lesson from Linux Journey (CC BY-SA 4.0).
Run two commands, then look at your history:
echo one
echo two
history
Each command has a number on the left.
!! reruns the last command. !-2 reruns the one before that, and !number reruns the command with that history number.
Run these three lines. The last one reaches two commands back, to echo one:
echo one
echo two
!-2
Bash shows the command it ran, then its output.
Run a command with a word you'll search for, then something else:
echo find-me
ls
Now press Ctrl+R and type find. Bash shows the most recent matching command. Press Enter to run it (or Ctrl+R again for an older match).
This finds commands from days ago without scrolling.
clear (or Ctrl+L) wipes the screen without touching your history:
clear
history | tail -5
history lists previous commands with numbers.!! reruns the last command; !-2 and !number rerun older ones.clear or Ctrl+L cleans the screen.