Did you know?
Ctrl+R searches your shell history as you type.
Press Ctrl+R again to jump to older matches, Enter to run, Ctrl+G to cancel.
- Shell & terminal
- Last checked
Explained
Scrolling up with the arrow keys to find a long command from yesterday is slow. Press Ctrl+R instead and start typing any part of the command. Bash shows the most recent match:
(reverse-i-search)`rsync': rsync -avz --delete /var/www/ backup:/srv/www/
While you are searching:
- Ctrl+R again moves to the next older match.
- Enter runs the command.
- Right arrow or Esc puts it on the command line so you can edit it first.
- Ctrl+G cancels and restores what you had typed.
To see every match at once, search the history with grep:
history | grep ssh
Then run an entry by its number, for example !1042. Bash keeps 1,000 commands in memory and 2,000 in ~/.bash_history with the default Ubuntu and Debian settings; raise HISTSIZE and HISTFILESIZE in ~/.bashrc to remember more.
Learn more
-
historycommand cheat sheet Options and copy-ready examples
