On the Linux command line, you often need to re-run previous commands. Let’s look at how to quickly find and, if necessary, change a command that you have already executed before.If this is a relatively recent command, you can simply press the Up key until the command appears. But if the command has been used for a long time, it is not always convenient.
There is another very simple and convenient way to search the command history — is to use keyboard shortcuts:
At the command prompt, simple press Ctrl+R.
You will be taken to the command history search mode. The prompt on the command line changes to:
As you type the characters, the command history will be automatically searched according to the characters you enter, and if the corresponding command is found, it will be displayed on the command line.
Press Ctrl+R again to move to the next command found. This is similar to navigating through the search results in a text editor when you use Ctrl+F.
The found command can be changed. To do this, press the Left or Right key to exit the search mode. The command appears on the command line and is editable.
To run the command, press Enter.
May the Force be with you,