Hot Keys and Shortcuts
The IOS CLI provides hot keys and shortcuts that make configuring, monitoring, and troubleshooting easier.
The figure shows most of the shortcuts. The following are worthy of special note:
- Down Arrow - Allows the user to scroll forward through former commands
- Up Arrow - Allows the user to scroll backward through former commands
- Tab - Completes the remainder of a partially typed command or keyword
- Ctrl-A - Moves to the beginning of the line
- Ctrl-E - Moves to the end of the line
- Ctrl-R - Redisplays a line
- Ctrl-Z - Exits the configuration mode and returns to user EXEC
- Ctrl-C - Exits the configuration mode or aborts the current command
- Ctrl-Shift-6 - Allows the user to interrupt an IOS process such as ping or traceroute
Examining some of these in more detail:
Tab complete is used to complete the remainder of abbreviated commands and parameters if the abbreviation contains enough letters to be different from any other currently available commands or parameters. When enough of the command or keyword has been entered to appear unique, press the Tab key and the CLI will display the rest of the command or keyword.
This is a good technique to use when you are learning because it allows you to see the full word used for the command or keyword.
Redisplay the line will refresh the line just typed. Use Ctrl-R to redisplay the line. For example, you may find that the IOS is returning a message to the CLI just as you are typing a line. You can use Ctrl-R to refresh the line and avoid having to retype it.
In this example, a message regarding a failed interface is returned in the middle of a command.
Switch# show mac-
16w4d: %LINK-5-CHANGED: Interface FastEthernet0/10, changed state to down
16w4d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to down
To redisplay to line that you were typing use Ctrl-R:
Switch# show mac
Exit configuration mode will leave any configuration mode and return to privileged EXEC mode. Because the IOS has a hierarchical mode structure, you may find yourself several levels down. Rather than exit each mode individually, use Ctrl-Z to return directly to the privileged EXEC prompt at the top level.
Up and Down Arrows
Previous command keys will recall the history of commands entered. The Cisco IOS software buffers several past commands and characters so that entries can be recalled. The buffer is useful for re-entering commands without retyping.
Key sequences are available to scroll through these buffered commands. Use the Up Arrow key (Ctrl-P) to display the previously entered commands. Each time this key is pressed, the next successively older command will be displayed. Use the Down Arrow key (Ctrl-N) to scroll forward through the history to display the more recent commands.
The escape sequence will interrupt any running process. When an IOS process is initiated from the CLI, such as a ping or traceroute, the command runs until it is complete or is interrupted. While the process is running, the CLI is unresponsive. To interrupt the output and interact with the CLI, press Ctrl-Shift-6.
This interrupts the entry of a command and exits the configuration mode. This is useful after entering a command that needs to be cancelled.
Abbreviated commands or keywords
Commands and keywords can be abbreviated to the minimum number of characters that identify a unique selection. For example, the configure command can be abbreviated to conf because configure is the only command that begins with conf. An abbreviation of con will not work because more than one command begins with con.
Keywords can also be abbreviated.
As another example, show interfaces can be abbreviated like this:
Switch# show interfaces
Switch# show int
You can abbreviate both the command and the keywords, for example:
Switch# sh int