[WayBack] bash – Search for a previous command with the prefix I just typed – Unix & Linux Stack Exchange answered by [WayBack] John1024:
What you are looking for isÂ
Ctrl-R
.TypeÂ
Ctrl-R
 and then type part of the command you want. Bash will display the first matching command. Keep typingÂCtrlR
 and bash will cycle through previous matching commands.To search backwards in the history, typeÂ
Ctrl-S
 instead. (IfÂCtrl-S
 doesn’t work that way for you, that likely means that you need to disable XON/XOFF flow control: to do that, runÂstty -ixon
.)This is documented under “Searching” inÂ
man bash
.
Comment by [WayBack] HongboZhu:
Ctrl-Q
 to quit the frozen state, if you already hitÂCtrl-S
 without turning off flow control first and got your terminal frozen.
A far more elaborate answer with many other tips is from [WayBack] Peter Cordes: