Streamline Your Command Line with `ctrl+r` and Shell History Expansion

Quick Tip

Streamline Your Command Line with `ctrl+r` and Shell History Expansion

Challenge: You often find yourself retyping long or complex commands, or trying to recall a command you used a while ago, leading to inefficiency and potential typos.

The Solution: Utilize the reverse-i-search feature (`Ctrl+R`) and shell history expansion for quick command recall and modification.

Ctrl+R

Why it works: Pressing `Ctrl+R` enters interactive history search. As you type, the shell searches your command history for matching commands. Press `Ctrl+R` again to cycle through older matches. Once you find the desired command, press `Enter` to execute it, or `Left Arrow` (or `Ctrl+A`) to edit it before execution.

Pro-Tip: Use `!!` to re-execute the very last command. Use `!` (e.g., `!ls`) to execute the last command that started with “ls”.

Linux Tips & Tricks | © ngelinux.com | 4/30/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments