Creating Command Aliases


You want to create aliases for commonly used or complex commands.


You can create command aliases on your router with the alias command:

Router1#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#alias exec rt show ip route
Router1(config)#alias exec on show ip ospf neighbor



Unix system administrators have been using command aliases for many years to help reduce typing and save time. These shortcut commands allow you to reduce long or complex command sequences to a few simple characters. This is most useful for extremely common commands, and for commands that are complex or difficult to remember. You can create an alias for any command, including some or all of its associated keywords or variables.

Here we have created the alias, rt, for one of the most common commands we use everyday, show ip route:

Router1(config)#alias exec rt show ip route

We can now use this simple two-letter command to display the routing table, saving time and typing:

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
 D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
 * - candidate default, U - per-user static route, o - ODR
 P - periodic downloaded static route

Gateway of last resort is to network

S [1/0] via is subnetted, 1 subnets
C is directly connected, FastEthernet0/0.2 is variably subnetted, 3 subnets, 3 masks
O [110/74] via, 00:52:55, Serial0/0.2
C is directly connected, Serial0/0.2
O [110/65] via, 00:52:55, Serial0/0.2 is variably subnetted, 2 subnets, 2 masks
D is a summary, 20:31:03, Null0
C is directly connected, FastEthernet0/1

The key to choosing a good alias command name is to pick something that is short and easy to remember. Of course, it is critical to select an alias that does not conflict with an existing command. In our example, we choose rt as a short, easy-to-remember mnemonic for "Route Table" that didn't conflict with any existing IOS command.

You can also use a command alias as part of a longer command. For example, we could use our rt alias to shorten the command show ip route

Routing entry for
 Known via "connected", distance 0, metric 0 (connected, via interface)
 Routing Descriptor Blocks:
 * directly connected, via FastEthernet0/0.2
 Route metric is 0, traffic share count is 1

Command aliases are most effective if you use them consistently among all the routers that you manage. Otherwise, you'll have to remember a different set of alias commands for each group of devices. If you want to use this feature, we recommend that the entire network management team work together to develop a standard set of aliases before implementing them. We also recommend keeping the aliases simple. Above all, resist the urge to alias every possible command. Instead, create aliases for only the most common commands.

Command aliases are also useful for scripting. You can build a script to perform a task on a router that might be slightly different on each router. For example, suppose you want to clear the counters of a particular access list on a weekly basis, but some of your routers use a different access list number. You can simply build an alias with the same name on each router, but make the actual commands represented by the alias appropriate to each individual router. Finally, you can build a script to issue the command alias and automate what would otherwise be an extremely onerous task.

The show alias command displays all the command aliases configured on the router:

Router1#show aliases
Exec mode aliases:
 h help
 lo logout
 p ping
 r resume
 s show
 u undebug
 un undebug
 w where
 rt show ip route
 on show ip ospf neighbor


If you type this command on any router, you will see that Cisco implements several command aliases by default.

Router Configuration and File Management

Router Management

User Access and Privilege Levels


IP Routing





Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time


Router Interfaces and Media

Simple Network Management Protocol





First Hop Redundancy Protocols

IP Multicast

IP Mobility




Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications


Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505 © 2008-2020.
If you may any questions please contact us: