Blog → Post


(TIP) ctrl-r
A very quick way to recall past CLI commands
by @admin, april 18, 2021, 02:01pm utc

We all know that using ctrl-c/crtl-v to copy & paste; and ctrl-z to (blessedly) be able to reverse one or more screw-ups; were truly great advancements in computing.

Well, ctrl-r on Linux is mighty helpful as well.

Pressing ctrl-r while in the terminal brings up a little processor, that lets you enter any string. It then shows you the line that you last used with that string in it. This is pretty convenient for remembering the parameters that you last used with any given command.

For example, typing ctrl-r, then scp brings up a history search starting with your last 'scp' copy command. Hitting the left or right arrow key switches this into an edit mode, where you can move back and forth to alter the line. Then just press Enter to execute it.

(reverse-i-search)`scp': scp cool_commands.html sally@149.20.4.15:/home/admin

What ctrl-r is doing is going back through your own history of terminal commands and displaying them to you in reverse order. If you press ctrl-r again while in the processor, it will show you the next previous time that you used that same string.

People who often use the same commands, but with different parameters, will come to love ctrl-r.

tags: All users, Tips
Footer done in Inkscape