If you want to see a collection of your previous commands used in Linux, you can always type ‘history’ for a listing of them. You can even search through history by grepping for the command you’re looking for, but then you’d have to copy/paste it into the terminal to run it again. Here’s a great shortcut to help you out!
Let’s say there was a long command you know you typed at some point but don’t remember the exact order of things within the command – or you just don’t feel like typing it all out again.
Use the reverse-i-search (ctrl-r)!
Start out at a command prompt. Hit the ctrl-r combination of keys..
Now, simply start typing anything within the command you’re searching for. Once you see some results, keep hitting ctrl-r to cycle through history until you see the command you want! Hit enter to execute it or hit the left or right arrow key to edit it before you execute it.
If you can’t find what you’re looking for, ctrl-c out of the search.
Related posts from Linux Brigade!
- Import MySQL database from command line You’ll need to import a database via command line from time to time – I’ll normally opt for this anyway. After seeing how easy it is, you’ll probably end up using the command line instead […]
- Learn the CSF command line options You have CSF installed and use the GUI to do most things. (If you don’t have it installed yet, you can read our article on how to install csf). BUT – knowing the csf (ConfigServer […]
- Migrating from Plesk to cPanel via commandline If you’re anything like me, you prefer to do things via command line (CLI) rather than relying on a GUI to do most things in Linux. You also realize that while some of us don’t like to use […]
- Add time and date to your bash history Often, you’ll go looking for a shell command that you used in the past – you can remember around when you did it but of course that won’t help you because by default the bash history won’t […]
- Download Linux – Links to 20 popular distributions I always find myself telling people to just download Linux. This usually follows up with “which distribution” and i’ll recommend a couple but always end with “try a few and see which one […]