Site icon New Generation Enterprise Linux

Effortless Command Recall with `Ctrl+R` and `fc`

Quick Tip

Effortless Command Recall with `Ctrl+R` and `fc`

Challenge: You’ve executed a complex command or a series of commands and now need to re-run it or a slight variation. Manually typing it again is tedious and error-prone.

The Solution: Leverage your shell’s history capabilities. For interactive recall, use Ctrl+R (reverse-i-search). For programmatic recall or editing, use the fc command.

# Interactive search for previous commands Ctrl+R # Edit and re-run the last command fc # Edit and re-run command number 150 fc 150 # Edit the last command, then run the edited version fc -e vim 

Why it works: Ctrl+R allows you to interactively search your command history by typing any part of the command you’re looking for. The fc (fix command) built-in opens the last executed command in your default editor (or a specified one) for modification before execution, or allows you to re-execute specific past commands by their number.

Pro-Tip: Combine Ctrl+R with typing keywords to quickly find specific commands, and use !! to re-run the very last command.

Linux Tips & Tricks | © ngelinux.com | 5/2/2026

0 0 votes
Article Rating
Exit mobile version