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 […]
Move MySQL tmp directory You’ll eventually run into a client who has a crashed table in their database – this table will be pretty large – maybe even larger than the system’s default temporary directory (usually […]
Delete files that are x days old Sometimes in Linux, you want to clear out older files in a directory. One instance would be if you have a security system and it continuously writes video files to a directory on your NAS […]