Terminal 101: Searching Through Previously Typed Commands

Every Monday, we’ll show you how to do something new and simple with Apple’s built-in command line application. You don’t need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type ’em out!

Have you ever used a command in the Terminal, but then later forgot what you typed, and wished there was some way that you could view the last used commands? Well, you’re in luck, because there are actually two ways to search through your command history, and we’ll show you how in this week’s Terminal 101. Continue reading to learn more.

Simple History Viewing

To simply view the last few commands that you’ve used, use the up and down arrows on your keyboard when at the command prompt.


Each time you press the up arrow, the command shown will change as you go backwards in your command history. Use the down arrow to move forward in time in your command history. If you see a command that you wish to run again, press the Enter key to run the command. The command will then be stored as the last used command.

Searching Through Command History

If you don’t have the time to navigate forward and back in your command history using the arrow keys, then there is a quicker alternative: You can search your way through your command history. Simply press Control + R when at the command prompt.


This will open the “bck-i-search” field. Begin typing in part of a command, and the command will begin searching through the previously used commands listing to find that portion of the command in your history. The more you type, the more the history will get narrowed down.

When the command you wish to use appears in the command line, press enter to run the command. The search interface will disappear when you do this.

Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow Cory Bohon on Twitter.