LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the bash shortcuts for history and other functions?

Bash remembers everything you type, so Ctrl+R searches that history, ↑/↓ step through it, !! re-runs the last command, and Esc+. grabs the last argument of the previous command.

The point is to almost never retype a command. Bash keeps a history list, and these shortcuts are different ways to fish things back out of it — by searching, by stepping, or by referencing. The single highest-value one is Ctrl+R: start typing any fragment and bash jumps to the most recent matching command.

Shortcut Action
Ctrl+R Reverse-search history — type a fragment to find it
/ (or Ctrl+P/Ctrl+N) Step to previous / next command
!! Re-run the last command verbatim
!n Re-run history command number n
!string Re-run the last command starting with string
Esc then . Insert the last argument of the previous command

That last one (Esc+.) is a hidden gem: after mkdir /opt/app/data, just type cd then Esc+. and bash drops /opt/app/data in for you — no retyping the long path.

Other useful shortcuts:

Shortcut Action
Ctrl+L Clear screen (same as clear)
Ctrl+C Cancel current command
Ctrl+D Exit shell (on empty line)
Ctrl+Z Suspend current process

Ctrl+R example:

(reverse-i-search)`ssh': ssh user@server.com
# Type 'ssh' and it finds your last ssh command
# Press Enter to run, or Ctrl+R again for older matches

Tip: history command shows all previous commands with numbers for !n.

From Quiz: LIOS / Files and Directories | Updated: Jul 14, 2026