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)
- 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)
A '?' by itself at a prompt
arp | Set arp type (arpa, probe, snap) or timeout | |
bandwidth | Set bandwidth informational parameter | |
cdp | CDP interface subcommands | |
crypto | Encryption/Decryption commands | |
description | Interface specific description | |
duplex | Configure duplex operation | |
exit | Exit from configure mode | |
ip | Interface Internet Protocol config commands | |
no | Negate a command or set its defaults | |
shutdown | Shutdown the selected interface | |
speed | Configure speed operation |
'?' directly after a character or a string of characters
'?' 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:
address-table | Configure the MAC address table |
aging-time | Set MAC address table entry maximum age | |
static | static keyword | |
learning | Enable MAC table learning feature |
H.H.H | 48 bit mac address |
vlan | VLAN keyword |
<1-4094> | VLAN id of mac address table |
interface | interface |
GigabitEthernet | GigabitEthernet IEEE 802.3 |
<cr> |
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 br | show ip interface brief |
sh ip rou | show ip route |
sh run | show running-config |
sh sta | show startup-config |
conf t | configure terminal |
wr mem | write memory |
copy run sta | copy running-config startup-config |
ip add | ip address |
shut | shutdown |
int g0/1 | interface 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:
address-table | Configure the MAC address table |
aging-time | Set MAC address table entry maximum age | |
static | static keyword | |
learning | Enable MAC table learning feature |
H.H.H | 48 bit mac address |
vlan | VLAN keyword |
<1-4094> | VLAN id of mac address table |
interface | interface |
GigabitEthernet | GigabitEthernet IEEE 802.3 |
<cr> |
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