I am a terminal n00b, but I’m liking it. I grew up on a M$ box and didn’t take the ‘leap’ to a linux / unix based operating system until about a year and a half ago when we got new computers at work. Since that time I have been trying to learn more about the terminal and am very impressed by it. I’ve been using OS X at work and Ubuntu at home and haven’t booted into windows (except for playing games) for almost a year.
Something that I found out in the recent months and finding very useful is the reverse-i-search. By pressing ctrl + r in the terminal (works at least in ubuntu and OS X, probably all real terminals) you are given a console line like the following:
(reverse-i-search)`':
As you type the terminal will search through your terminal history and locate any commands that contain what you search.
For instance if you type ssh it will start searching through the history and show you the last one that you used that had ssh in the command. If the first result isn’t the one that you are looking for you can press ctrl + r to keep the search going and cycle back through your history.
I am still amazed by all the things that I am learning about *nux operating systems and I am only touching the surface.
Comments
Do you know how to come back in your search.. like repeat Ctr-r…reverse
Hey karthi,
I couldn’t find anything about going back up individually. But there is a question on stack overflow that suggests that following:
Cool!! I typed this in by accident in cygwin/bash (I thought I was in Eclipse and was about to open a file with ctrl-shit-r) and found your post as explanation.
Much appreciated!
up/down arrows cycle back through previous commands in bash.
I believe both are just reading through ~/.bash_history
Yup, they both use your ~/.bash_history, one just uses a search instead of one at a time.