Skip to content
Course/Keyboard Shortcuts/Command History

Command History

Browse and reuse past commands with arrow keys and the history command.

The terminal remembers every command you've run. Instead of retyping commands you've already used, you can navigate through your command history to find and reuse them. This is one of the biggest time-savers in everyday terminal use.
Up Arrow     Show the previous command from history
Down Arrow   Show the next command from history
history      List all recent commands with line numbers
Pressing the Up arrow cycles backward through your command history — the most recent command appears first. Press it again to go further back. Down arrow moves forward toward your most recent commands. If you press Down enough times, you'll get back to an empty prompt.
The history command prints a numbered list of all your recent commands. This is useful when you want to see what you've been running, or when you need the exact text of a command from several sessions ago. The numbers next to each command can be used with history shortcuts, which we'll cover in a later lesson.

Build a habit: before retyping a command, press Up a few times. The command you need is almost always in your recent history. Advanced users rarely type the same command twice.

Your terminal already has some commands in its history from earlier work. Try pressing Up a few times to browse through them. Then pull up your full command history to see everything listed with line numbers.
Practice