Help, autocompletion, monitoring, shortcuts
Published on 11 min read
Updated on
In this series39 min read in total
The Cisco CLI has no mouse, no menu and no contextual help message. Everything happens on a command prompt and a handful of conventions, the same ones for decades. Knowing them turns a painful session into fast work.
This article follows a real session: first knowing where you are, then typing fast and right, making the console bearable, reading what the device holds, and finally changing then saving.
Getting your bearings: the CLI modes
It all starts with the prompt. It permanently shows two things: the device name, and the mode you are in. That mode determines which commands are accepted, and it is the number one cause of “invalid command” among beginners.
| Prompt | Mode | What you do there | How to get in |
|---|---|---|---|
Switch> | user EXEC | very limited read-only access | the default landing mode |
Switch# | privileged EXEC | every show, reload, saving | enable |
Switch(config)# | global configuration | settings for the whole device | configure terminal |
Switch(config-if)# | interface configuration | settings for one specific port | interface FastEthernet0/1 |
Switch(config-line)# | line configuration | console, VTY, remote access | line console 0 |
You go down the hierarchy by naming what you want to configure, and back up with exit, one level at a time. CTRL + Z jumps straight back to privileged mode from any depth.
enableSwitch#configure terminalSwitch(config)#interface FastEthernet0/1Switch(config-if)#exitSwitch(config)#Once the mode is identified, the command still has to be typed, and the device offers several aids for that.
Typing less and getting it wrong less
The question mark
? lists the options available at the point you have reached in the command.
show ? aaa Show AAA values access-lists List access lists arp Arp table cdp CDP information class-map Show QoS Class Map clock Display the system clock controllers Interface controllers status crypto Encryption module debugging State of each debugging option dhcp Dynamic Host Configuration Protocol status dot11 IEEE 802.11 show information file Show filesystem information flash: display information about flash: file system flow Flow information frame-relay Frame-Relay information history Display the session command history hosts IP domain-name, lookup style, nameservers, and host table interfaces Interface status and configuration ip IP information ipv6 IPv6 information license Show license information line TTY line information--More--The --More-- marker means the list is taller than the window. Enter scrolls line by line, Space screen by screen, and Q aborts the display.
Autocompletion
The TAB key completes a command as soon as it is no longer ambiguous: sh becomes show, int becomes interface. As long as several commands share the same beginning, one more letter is needed to lift the ambiguity.
Abbreviations
You do not even need to complete: the CLI accepts any unambiguous abbreviation as is.
| Abbreviation | Full command |
|---|---|
conf t | configure terminal |
sh run | show running-config |
sh ip int b | show ip interface brief |
wr | write memory |
int g0/0 | interface GigabitEthernet0/0 |
no shut | no shutdown |
The error report
When a command is rejected, the device points at the exact spot of the problem with a caret.
sh ip routte ^% Invalid input detected at '^' marker.The marker sits on the first character the parser could not interpret. Here everything before it is valid, the mistake really is on routte.
Keyboard shortcuts
| Sequence | Description |
|---|---|
| CTRL + A | Start of line |
| CTRL + E | End of line |
| CTRL + P or ↑ | Previous command |
| CTRL + N or ↓ | Next command |
| CTRL + F or → | Cursor right |
| CTRL + B or ← | Cursor left |
| ESC + f | Forward one word |
| ESC + b | Back one word |
| CTRL + W | Delete previous word |
| CTRL + U | Delete the whole line |
| CTRL + R | Redisplay the current line |
| CTRL + Z | Back to privileged mode |
| CTRL + C | Interrupt the command |
| CTRL + SHIFT + 6 | Forced break, for a stuck ping or traceroute |
| TAB | Complete the command |
Those aids are enough to type fast. The console still has to stop working against you.
Making the console usable
Three IOS default behaviours get in the way constantly. Each one is disabled with a single command.
DNS resolution of typos
In privileged mode, an unknown command is interpreted as a hostname to reach. The device then attempts a DNS lookup and locks the console for several tens of seconds.
showeTranslating "showe"...domain server (255.255.255.255)no ip domain-lookupMessages that cut into your typing
Every interface state change writes a message on the console, right in the middle of whatever you are typing.
%LINK-1-CHANGED: Interface FastEthernet0/1, changed state to upTwo possible answers, and the second one is almost always the right one.
line console 0logging synchronousMessages keep showing up, but the device redisplays your current line right below. You keep the information without losing your typing. This is the setting to apply by default on any console.
no logging consoleMessages stop showing up entirely. Comfortable during a long configuration, but you also lose the useful alerts, such as an interface refusing to come up. Keep it for cases where the noise is truly unmanageable, and turn it back on afterwards.
Pagination
The --More-- prompt forces a keypress on every screen, which prevents copying an entire configuration in one block.
terminal length 0The value 0 removes pagination for the current session only. It returns to normal on reconnect, which makes it a risk-free setting.
The console is now cooperative. Time to read the device.
Reading the device configuration
The general configuration
show running-configBuilding configuration...
Current configuration : 1080 bytes!version 15.0no service timestamps log datetime msecno service timestamps debug datetime msecno service password-encryption!hostname Switch!!!!!!spanning-tree mode pvstspanning-tree extend system-id!interface FastEthernet0/1!interface FastEthernet0/2--More--This command shows the configuration active in memory: hostname, services, interfaces, spanning-tree, passwords. It is the starting point of any diagnosis.
The VLAN configuration
show vlan
VLAN Name Status Ports---- -------------------------------- --------- -------------------------------1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 Gig0/1, Gig0/21002 fddi-default active1003 token-ring-default active1004 fddinet-default active1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------1 enet 100001 1500 - - - - - 0 01002 fddi 101002 1500 - - - - - 0 01003 tr 101003 1500 - - - - - 0 01004 fdnet 101004 1500 - - - ieee - 0 01005 trnet 101005 1500 - - - ibm - 0 0--More--Every interface from Fa0/1 to Fa0/24 and Gig0/1 to Gig0/2 belongs to VLAN 1, the default one.
Filtering the output
A configuration several hundred lines long is unreadable as is. The | character filters the output of any show command.
sh run | include interfaceinterface GigabitEthernet0/0/0interface GigabitEthernet0/0/1interface GigabitEthernet0/0/2interface Vlan1Four filters cover nearly every need:
| Filter | Effect | Example |
|---|---|---|
include | keeps only the lines containing the pattern | sh run | include hostname |
exclude | drops the lines containing the pattern | sh run | exclude ! |
begin | starts the output at the first matching line | sh run | begin interface |
section | shows the whole configuration block | sh run | section interface Fa0/1 |
With the reading done, on to changes.
Changing, undoing and saving
Renaming the device
hostname MY_SWITCHThe change is immediate and visible in the prompt, which avoids configuring the wrong device in a room holding ten of them.
Protecting privileged mode
enable secret MY_PASSWORDUndoing with no
The no prefix removes, disables or clears any command entered before. It is the universal undo mechanism of IOS.
no ip address 192.168.1.1 255.255.255.0Removes the IP address assigned to the interface.
no router ospf 1Disables OSPF and deletes its entire configuration.
Running a command from another mode with do
show commands belong to privileged mode and are rejected in configuration mode. The do prefix runs them without leaving the current mode.
show run ^% Invalid input detected at '^' marker.
Switch(config)#do show runBuilding configuration...This avoids the exit then configure terminal round trip, and therefore avoids losing the interface context you were working in.
Saving, the step everyone forgets
A Cisco device keeps two distinct configurations, and that is the most expensive source of mistakes in the CLI.
| Configuration | Where it lives | What happens to it on reboot |
|---|---|---|
running-config | in RAM | lost |
startup-config | in non-volatile memory | reloaded as is |
Every command in this article changes the running-config, and takes effect immediately. None of them survives a power cut until it has been copied over.
copy running-config startup-configwrite memoryBoth commands do the same thing, the second being the historical shorthand, hence the wr in the abbreviations table. To check what will actually be reloaded:
show startup-configThese reflexes, modes, built-in help, filters and saving, come back as is in the other articles of the series, which apply them to VLAN, routing and remote access configuration.