Skip to main content
Xsec

Help, autocompletion, monitoring, shortcuts

Published on 11 min read

Updated on

Part 4 of 6
In this series39 min read in total
  1. LAYER 2 Vlan, Spanning-tree, Trunk, EtherChannel, and Dot1Q Encapsulation
  2. LAYER 3 Static Routing, RIPv2, OSPF, NAT
  3. The hierarchy of CLI cisco
  4. Help, autocompletion, monitoring, shortcuts
  5. Alcatel Switch Configuration
  6. Remote Access

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.

PromptModeWhat you do thereHow to get in
Switch>user EXECvery limited read-only accessthe default landing mode
Switch#privileged EXECevery show, reload, savingenable
Switch(config)#global configurationsettings for the whole deviceconfigure terminal
Switch(config-if)#interface configurationsettings for one specific portinterface FastEthernet0/1
Switch(config-line)#line configurationconsole, VTY, remote accessline 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.

Switch>
enable
Switch#configure terminal
Switch(config)#interface FastEthernet0/1
Switch(config-if)#exit
Switch(config)#
TipRead the prompt before hunting for the error

A rejected command is far more often a command typed in the wrong mode than a misspelled one. show running-config does not work in (config)#, ip address does not work in #. The useful reflex is reading the prompt before rereading the command.

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.

Router#
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.

Tip? also works mid-word

Typed against the start of a word, sh?, it lists commands starting with those letters. Typed after a space, show ?, it lists the possible arguments. This is the device’s built-in documentation, available even with no network.

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.

AbbreviationFull command
conf tconfigure terminal
sh runshow running-config
sh ip int bshow ip interface brief
wrwrite memory
int g0/0interface GigabitEthernet0/0
no shutno shutdown
WarningAbbreviations help you, they do not document

They are perfect in an interactive session. In a script, a procedure or a capture meant for a colleague, write the full command: an abbreviation that turns ambiguous on another IOS version produces an error that is hard to understand for whoever reads it.

The error report

When a command is rejected, the device points at the exact spot of the problem with a caret.

Router#
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

SequenceDescription
CTRL + AStart of line
CTRL + EEnd of line
CTRL + P or Previous command
CTRL + N or Next command
CTRL + F or Cursor right
CTRL + B or Cursor left
ESC + fForward one word
ESC + bBack one word
CTRL + WDelete previous word
CTRL + UDelete the whole line
CTRL + RRedisplay the current line
CTRL + ZBack to privileged mode
CTRL + CInterrupt the command
CTRL + SHIFT + 6Forced break, for a stuck ping or traceroute
TABComplete the command
NoteThese are the Emacs shortcuts

CTRL+A start of line, CTRL+E end of line, CTRL+P previous, CTRL+N next: these are exactly the Emacs conventions, picked up by readline and therefore by bash. Reflexes built in a GNU/Linux terminal transfer straight onto a Cisco device.

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.

Switch#
showe
Translating "showe"...domain server (255.255.255.255)
Switch(config)#
no ip domain-lookup
Warning

This command disables all name resolution on the device, including the one you might need for a ping www.example.com. On a production device that genuinely uses DNS, prefer configuring a reachable server with ip name-server rather than cutting everything off.

Messages that cut into your typing

Every interface state change writes a message on the console, right in the middle of whatever you are typing.

Terminal
%LINK-1-CHANGED: Interface FastEthernet0/1, changed state to up

Two possible answers, and the second one is almost always the right one.

Switch(config)#
line console 0
logging synchronous

Messages 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.

Switch(config)#
no logging console

Messages 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.

Switch#
terminal length 0

The 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

Switch#
show running-config
Building configuration...
Current configuration : 1080 bytes
!
version 15.0
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
!
!
!
!
spanning-tree mode pvst
spanning-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

Switch#
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/2
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 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.

Note

VLANs 1002, 1003, 1004 and 1005 are reserved by the system for Token Ring and FDDI. Those technologies being obsolete, these VLANs are never used and cannot be deleted.

Filtering the output

A configuration several hundred lines long is unreadable as is. The | character filters the output of any show command.

Router#
sh run | include interface
interface GigabitEthernet0/0/0
interface GigabitEthernet0/0/1
interface GigabitEthernet0/0/2
interface Vlan1

Four filters cover nearly every need:

FilterEffectExample
includekeeps only the lines containing the patternsh run | include hostname
excludedrops the lines containing the patternsh run | exclude !
beginstarts the output at the first matching linesh run | begin interface
sectionshows the whole configuration blocksh run | section interface Fa0/1
Tipsection is the most useful of the four

include returns only the matching line, which rarely helps for an interface whose configuration spans five lines. section returns the whole block, indentation included, and gives the full context straight away.

With the reading done, on to changes.

Changing, undoing and saving

Renaming the device

Switch(config)#
hostname MY_SWITCH

The change is immediate and visible in the prompt, which avoids configuring the wrong device in a room holding ten of them.

Protecting privileged mode

Switch(config)#
enable secret MY_PASSWORD
Importantsecret, not password

enable password stores the password in clear text in the configuration, readable by anyone running a show running-config. enable secret stores a hash of it. Both can coexist, and in that case secret wins. There is no reason to use enable password today.

Undoing with no

The no prefix removes, disables or clears any command entered before. It is the universal undo mechanism of IOS.

Router(config-if)#
no ip address 192.168.1.1 255.255.255.0

Removes the IP address assigned to the interface.

Router(config)#
no router ospf 1

Disables OSPF and deletes its entire configuration.

Warning

no on a whole block, such as no router ospf 1, wipes every line it contained at once. There is no undo for the undo: the only way back is the saved configuration, which is what the next section is about.

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.

Switch(config)#
show run
^
% Invalid input detected at '^' marker.
Switch(config)#do show run
Building 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.

ConfigurationWhere it livesWhat happens to it on reboot
running-configin RAMlost
startup-configin non-volatile memoryreloaded 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.

Switch#
copy running-config startup-config
Switch#
write memory

Both 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:

Switch#
show startup-config
TipNot saving can be a strategy

On a risky remote change, such as re-addressing or an access control list, not saving is a safety net: if you lose your hand on the device, a reboot restores the last working configuration. Only save once connectivity is confirmed.

These 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.

Use with an AI

Actions