Search previous commands typed

Rob —  August 21, 2014 — Leave a comment

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 lineImport 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 commandlineMigrating 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 […]
  • Back up all of your mysql databases nightlyBack up all of your mysql databases nightly Have you ever wanted to make your own MySQL database backups?  You can use this script I wrote to make a backup of all databases, then save each one in a dated backup directory.  It will […]
  • Install nrpe on XenServerInstall nrpe on XenServer If you are using nagios in your hosting environment and need to install nrpe on your XenServer servers, here’s a good way to do it.
    I’m using XenServer 6.1 (latest version).

    First, […]

No Comments

Be the first to start the conversation.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

*