Sign Up|Login Courses & Workshops
Overview
Pricing
CISCO REFERENCE HOME

Cisco CLI Tips and Tricks

Cisco's Command Line Interface supports shortcuts and features that speed up our ability to perform configuration and administration tasks. Familiarizing ourselves with these shortcuts allows us to perform CLI tasks quickly and efficiently.

In this post we list out some of these shortcuts and features and how to get the most out of them.

Command History (↑ and ↓ keys)
Command History is a useful feature found on most Command Line Interfaces (including Linux terminals, Windows Command Prompts and most network device command line interfaces). It allows a user to scroll through previously typed commands at a CLI prompt. This is particularly useful for the following purposes:
  • Type in a command only once - access the same command by simply using the ↑ key
  • When the same command has to be entered multiple times, with different parameters each time, you can speed up the process by accessing the previously typed in command (by using the ↑ and ↓ keys) and changing only the parameters required.
Context-sensitive help ('?' key)
At a Cisco CLI prompt, the '?' key can be used at any time to obtain context-sensitive help. Here are a few use cases and examples:
A '?' by itself at a prompt
When used by itself at a prompt, the '?' generates a list of commands available in the current CLI mode. The example below shows the output of a '?' by itself when a Cisco Router is in Interface Configuration Mode. (The output is truncated.)
Router Console
Router(config-if)#?
Interface configuration commands:
arpSet arp type (arpa, probe, snap) or timeout
bandwidthSet bandwidth informational parameter
cdpCDP interface subcommands
cryptoEncryption/Decryption commands
descriptionInterface specific description
duplexConfigure duplex operation
exitExit from configure mode
ipInterface Internet Protocol config commands
noNegate a command or set its defaults
shutdownShutdown the selected interface
speedConfigure speed operation
Router(config-if)#
Most common use: This is useful when you have a vague idea that a command exists, but don't recall it exactly, or are unsure which mode it is available in. It is also useful to get a general idea of all the commands avaialable in any CLI Mode.
'?' directly after a character or a string of characters
When a '?' is typed in directly after a character or a string of characters (with no space between the last character and the '?') the CLI terminal lists out all the possible commands, keywords or arguments that begin with the string of characters preceding the '?'.
The first example shows the output as we start with the letter 'c' in Privileged EXEC Mode. As we keep adding more letters, the list of available options is narrowed down to match only those options that begin with the charaters typed out.
Router Console
Router#c?
clearclockconfigureconnectcopy
Router#co?
configureconnectcopy
Router#con?
configureconnect
Router#conf?
configure
Router#conf
If there is no match for the characters typed out, the CLI responds with an "% Unrecognized command" message as shown below.
Router Console
Router#c?
clearclockconfigureconnectcopy
Router#co?
configureconnectcopy
Router#con?
configureconnect
Router#conf?
configure
Router#conft
% Unrecognized command
Router#conft
'?' after a word preceded by a space

When a '?' is used after a word (or sequence of words) and preceded by a space, the CLI prints out all of the available keywords or arguments for the command that has been typed in.

This is particularly useful when we have a vague that a command exists, but are unsure of the exact .

For example, suppose we want to add a static mac address entry to a switch's Mac Address Table. We might recall that the command starts with the word "mac". We can use the context-sensitive help to figure out all the required arguments and keywords.

We know that the command is a Global Configuration Mode command. We enter Global Configuration Mode, and then type in the word "mac" followed by a space and a '?'

We choose the appropriate argument from the list of options and continue on using a '?' (preceded by a space) to discover all of the required arguments as displayed below:

Switch Console
Switch#configure terminal
Switch(config)#mac ?
address-tableConfigure the MAC address table
Switch(config)#mac address-table ?
aging-timeSet MAC address table entry maximum age
staticstatic keyword
learningEnable MAC table learning feature
Switch(config)#mac address-table static ?
H.H.H48 bit mac address
Switch(config)#mac address-table static 202e.8beb.4ac0 ?
vlanVLAN keyword
Switch(config)#mac address-table static 202e.8beb.4ac0 vlan ?
<1-4094>VLAN id of mac address table
Switch(config)#mac address-table static 202e.8beb.4ac0 vlan 10 ?
interfaceinterface
Switch(config)#mac address-table static 202e.8beb.4ac0 vlan 10 interface ?
GigabitEthernetGigabitEthernet IEEE 802.3
Switch(config)#mac address-table static 202e.8beb.4ac0 vlan 10 interface Gi0/1 ?
<cr>
Switch(config)#mac address-table static 202e.8beb.4ac0 vlan 10 interface Gi0/1
Switch(config)#
Command abbreviation

Another neat (and time-saving) feature of Cisco's CLI is the Command abbreviation feature. At a Cisco CLI prompt, we do not need to type in every word in every command in its entirety. The CLI allows us to enter partial words as commands. We are only required to type in enough characters to uniquely identify a word (command, keyword or argument).

The acceptable abbreviated forms of some of the most common commands are as follows:

sh ip int brshow ip interface brief
sh ip roushow ip route
sh runshow running-config
sh stashow startup-config
conf tconfigure terminal
wr memwrite memory
copy run stacopy running-config startup-config
ip addip address
shutshutdown
int g0/1interface GigabitEthernet 0/1

Command abbreviation can be used along with context-sensitive help. For example, in the previous scenario (for the mac address-table static command) we could use abbreviated words to trigger the context-sensitive help as shown below:

Switch Console
Switch#conf t
Switch(config)#mac ?
address-tableConfigure the MAC address table
Switch(config)#mac add ?
aging-timeSet MAC address table entry maximum age
staticstatic keyword
learningEnable MAC table learning feature
Switch(config)#mac add st ?
H.H.H48 bit mac address
Switch(config)#mac add st 202e.8beb.4ac0 ?
vlanVLAN keyword
Switch(config)#mac add st 202e.8beb.4ac0 vl ?
<1-4094>VLAN id of mac address table
Switch(config)#mac add st 202e.8beb.4ac0 vl 10 ?
interfaceinterface
Switch(config)#mac add st 202e.8beb.4ac0 vl 10 int ?
GigabitEthernetGigabitEthernet IEEE 802.3
Switch(config)#mac add st 202e.8beb.4ac0 vl 10 int Gi0/1 ?
<cr>
Switch(config)#mac add st 202e.8beb.4ac0 vl 10 int Gi0/1
Switch(config)#

The key point to remember is that for command abbreviation to work, we need to enter at least enough characters to uniquely identify the word we intend to abbreviate.

Command auto-completion (TAB key)

Cisco CLI also features a command auto-complete function. This can be triggered by using the TAB key. This feature also requires us to type in at least enough characters to uniquely identify a word (command, keyword or argument). Once we have typed in enough characters to uniquely identify a word, we can press the TAB key to have the word auto-completed for us.

Pasting text at the CLI Promt (Ctrl+V or right-click → Paste)

Cisco CLI also allows a user to paste configuration commands directly into the CLI window. This is particularly useful when a number of devices have to be configured in succession.

Instead of configuring each device one line at a time, we can create a text file containing the configuration for the first device. We can then copy and paste this config into a new file and make the necssary changes for the second device. We follow this process for each device that needs to be configured.

Once we have all of the configuration ready in text document we can simply copy and paste the appropriate configuration into each device's CLI prompt.

Let's take a simple example, suppose we need to configure 2 interfaces on 2 different routers. We could create a text document with the following text:

Router 1

en
conf t

int gi0/0
ip address 192.168.10.1 255.255.255.0
no shut

int gi0/1
ip address 172.16.0.1 255.255.255.252
no shut

Router 2

en
conf t

int gi0/0
ip address 192.168.20.1 255.255.255.0
no shut

int gi0/1
ip address 172.16.0.2 255.255.255.252
no shut

We can now simply copy the lines of text for each router and paste them into the CLI window. This is much faster than typing in the config one line at a time!

Note: Connected Dots Cisco device simulators support each of the features mentioned above.

Want to test your networking skills with hands-on configuration and troubleshooting questions? Try out the Workshops section of this website here: Workshops (Login required).

Read how to use the device simulators on this website here: Workshops - General Instructions