One of the fastest ways to search your previous commands is to use CTRL+R and start typing, once you’ve entered enough text you can use CTRL+R again and again to search your history for matches.
Let’s assume we execute the following commands:
$ echo dog dog $ echo cat cat $ echo hotdog hotdog
Now press CTRL+R and you will see a new “bck:” prompt at the bottom:
Now if you type “dog” you will see the last command that had that string anywhere in it, populated on the previous command prompt:
$ echo hotdog bck:dog
Pressing CTRL+R again will cycle through the history:
$ echo dog bck:dog
You can press ENTER to execute the command, or CTRL+E to go to the end of the command without executing it.
I also hear you can use CTRL+S to go backwords through the search results, but that never works for me – I believe my terminal or window manager is swallowing the CTRL+S.