Terminal power users already know that a log of all the commands you execute are kept in history . (Go ahead, type history to see them.) Last week we saw that you can sudo your previous command using the !! (bang-bang) notation. Well, you can also search your command history as you type using the very useful Ctrl+R key combination.

Sudo !! the previous command Click to view Our latest featured reader screencast comes in from Dana, a system administrator who Read more






Give it a try: in the terminal, hold down Ctrl and press R to invoke "reverse-i-search." Type a letter - like s - and you'll get a match for the most recent command in your history that starts with s. Keep typing to narrow your match. When you hit the jackpot, press Enter to execute the suggested command.

Also, !characters will execute the last command that matches the specified characters. (So !ssh will run the last ssh you used.)


Of course good history search only works if you've got a long history. To extend the length of the history list in your terminal, add the following lines to your .bash_profile :

HISTFILESIZE=1000000000

HISTSIZE=1000000

Once you've got your history built up, you can use this command to see what items you type in the terminal the most. (Great way to decide what aliases you need to set up.) What are your favorite terminal history tricks? Let us know in the comments. Thanks, Tom!

What's in your bash History? [ONLamp]