IntroToLinux

3. Command History

History Features:

The shell remembers commands you’ve typed, making it easy to repeat or modify previous commands.

History Commands:

# Show command history
history

# Show last 10 commands
history 10

# Clear history
history -c

# Search history
history | grep keyword

History Navigation Shortcuts:

# Previous command
!!

# Previous command with modification
!!:s/old/new/

# Command from history by number
!number
!150

# Last command starting with specific text
!text
!ls    # Last command starting with 'ls'

# Previous command's last argument
!$

Arrow Keys:

Bash Arrow History

Next: → Command Line Editing
Previous: ← Environment Variables
Lesson Home: ↑ Lesson 3: History & Variables Course Home: ⌂ Introduction to Linux