VMware ESXi and vSphere Cluster Management
Display and Manage Cisco IOS Command History
Learn how to display, recall, verify, and change Cisco IOS command history during a terminal session using show history, show terminal, and terminal history size.
Cisco IOS is the operating system and command-line interface used by many Cisco routers and switches. During a terminal session, IOS can retain commands that you previously entered. This command history helps you reuse commands without typing them again.
Command history is stored in a session-specific history buffer. The buffer holds a limited number of recent commands for the current console, SSH, Telnet, or other terminal session.
Purpose of Cisco IOS Command History
Command history is the list of commands previously entered in a CLI terminal session. It improves efficiency when you need to repeat a verification command, correct a similar command, or inspect commands entered a few moments earlier.
For example, instead of typing a long interface or verification command again, you can recall it, edit a parameter, and press Enter. The history list applies to commands entered in the current terminal session; it is not automatically a permanent record of every command ever entered on the device.
Displaying Previously Entered Commands
Use show history to display commands retained in the current terminal history buffer.
Router> show history
show version
show ip interface brief
show history
The exact formatting and visible entries can vary by IOS platform and terminal session. By default, IOS retains 10 commands. If fewer than 10 commands have been entered, the output contains fewer entries. As new commands exceed the buffer capacity, older entries are removed.
show history is an EXEC command available from both user EXEC mode and privileged EXEC mode.
Router> show history
Router# show history
| Command | EXEC mode availability | Purpose | Key result |
|---|---|---|---|
show history | User EXEC and privileged EXEC | Display commands retained in the current terminal-session history buffer. | Shows the entries currently stored in the history list. |
show terminal | User EXEC and privileged EXEC | Display characteristics of the active terminal session. | Includes the configured terminal history size. |
terminal history size NUMBER | User EXEC and privileged EXEC | Set the maximum number of commands retained for the active session. | Changes the session's history-buffer capacity. |
Recalling Commands Interactively
You can recall commands directly at the IOS prompt using the keyboard. This is different from show history: the command displays the retained list, while the arrow keys move through entries so you can edit or execute them.
| Key | Action | Typical use |
|---|---|---|
| Up Arrow | Recalls a previous command, beginning with the most recently entered command. | Repeat a recent verification command or move backward toward older commands. |
| Down Arrow | Moves in the opposite direction through recalled entries, toward newer commands. | Return toward a more recent entry after pressing Up Arrow several times. |
Example: Recalling and Editing a Command
- At the IOS prompt, press Up Arrow once to recall the latest command.
- Press Up Arrow again to move to an older command.
- Edit the recalled command using normal CLI editing keys.
- Press Enter to execute the edited command.
- Press Down Arrow to move back toward newer recalled entries.
Switch# show ip interface brief
Switch# show version
<Press Up Arrow>
Switch# show version
<Edit or accept the command, then press Enter>
The Up Arrow normally starts with the latest command available in the current history list. The Down Arrow does not display a separate history list; it navigates through commands that you have already begun recalling.
Checking the Current History-Buffer Size
Use show terminal to inspect characteristics of the active terminal session. Its output includes the configured terminal history size. The exact labels and layout can differ between IOS releases and platforms.
Router# show terminal
<terminal characteristics>
<history-size information, such as a history buffer size of 10>
<additional terminal information>
The history size is the buffer's capacity, not necessarily the number of commands currently displayed by show history. For example, a buffer size of 50 means the session can retain up to 50 commands; it does not mean that 50 commands have already been entered.
Changing History-Buffer Size for the Current Session
Use terminal history size NUMBER to set the maximum number of commands retained by the active terminal session.
Router> terminal history size 50
Router> show terminal
Router> show history
In this example, 50 is the requested maximum number of retained commands. The command can be entered from user EXEC or privileged EXEC mode:
Router> terminal history size 50
Router# terminal history size 50
The setting applies to the current terminal session. It is not a permanent, device-wide configuration command. If you disconnect and establish a new session, verify the new session's value with show terminal and reapply the command when necessary.
Choosing a Suitable Size
The default size of 10 is often sufficient for short troubleshooting sessions. A larger value, such as 50, can be convenient during maintenance or study sessions when many related commands are entered. Choose a size that supports your workflow without treating the buffer as a permanent operational record.
| Item | Behavior |
|---|---|
| Default history capacity | IOS commonly retains 10 commands for the terminal session unless the session value is changed. |
| Configured history capacity | The value set by terminal history size NUMBER is the maximum number of commands retained by that session. |
| Session scope | The history belongs to the active terminal session, such as a particular console or remote CLI connection. |
| Behavior after disconnect | History may be lost when the session ends or reconnects. A new session may start with its own history list and default settings. |
Complete Session Example
The following workflow increases the active session's capacity, verifies the setting, and displays the retained commands.
Router> terminal history size 50
Router> show terminal
<verify that the terminal history size is 50>
Router> show history
<review commands retained in this session>
After entering more commands, press Up Arrow to recall the latest entry, press Up Arrow repeatedly to move toward older entries, and press Down Arrow to move toward newer entries.
Troubleshooting Command History
show history Displays Fewer Commands Than Expected
- The session may not yet have accumulated enough commands.
- Older commands may have been removed after the buffer reached its configured capacity.
- The current history size may still be the default value.
- Run
show terminalto verify the active history size. - If appropriate, run
terminal history size NUMBERwith a larger value. - Enter additional commands and run
show historyagain.
Commands Cannot Be Recalled After Reconnecting
The previous terminal session ended, so its session-specific history may no longer be available. Start a new history list for the new session. If persistent command records are required, use documented procedures, saved configurations, logs, or change-management records.
Arrow Keys Print Characters or Do Not Navigate History
- Confirm that the CLI session is active and that the cursor is at an IOS command prompt.
- Check the terminal emulator's keyboard and VT/ANSI compatibility settings.
- Use
show historyto view retained entries while interactive key handling is being corrected.
The History Size Does Not Remain Set Later
terminal history size NUMBER changes the active session only. Run show terminal in the current session to confirm its value. After opening a new session, reapply the command if a larger history buffer is needed.
Operational Limitations
Command history is a convenience feature, not a substitute for configuration backups, change records, logging, or command auditing. It may be lost when a terminal session ends, and command visibility or behavior can depend on the CLI session, platform, and IOS software behavior.
Use history to work efficiently in the moment. Use approved documentation and logging procedures when you need a durable record of administrative actions.
Exam-Relevant Notes
show historydisplays commands retained in the current terminal history buffer.- The common default history capacity is 10 commands.
- The Up Arrow recalls older commands, beginning with the most recent command.
- The Down Arrow moves toward newer commands during interactive recall.
show terminalverifies the configured history size for the active terminal session.terminal history size NUMBERchanges the maximum retained command count for the current session, not permanently for the device.- User EXEC mode commonly ends with
>; privileged EXEC mode commonly ends with#. The history commands covered here are available in both modes.
For related CLI skills, see Cisco IOS command history.