Cisco Command Christmas Calendar #10: alias

The alias command is underused, underrated, and undervalued. I've used it without even knowing about it. Aptly named, the alias command enables the creation of a command alias. You can use simple words or abbreviations, instead of writing a long command. For example, the commonly used s run (run short for running-config) command actually contains two default command aliases. The s is an alias for show and running-config is an alias for system:running-config.

R10#s run
Building configuration...

Current configuration : 3409 bytes
!
! Last configuration change at 19:29:38 UTC Sat Dec 9 2017
!
version 15.6
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R10
!
--More--


 These predefined basic EXEC mode aliases are enabled by default:

Command Alias Original Command
h help
lo logout
p ping
r resume
s show
w where


Common keyword aliases (which cannot be disabled) include running-config (keyword alias for system:running-config) and startup-config (keyword alias for nvram:startup-config).

Note that aliases can be configured for keywords instead of entire commands. You can create, for example, an alias for the first part of any command and still enter the additional keywords and arguments as normal. Like the alias s  works for all show commands.

To create your own alias, the command syntax is alias mode command-alias original-command. The mode is the command mode in which you would issue the original command, exec is used in many cases. For example, to shorten the show ip interface brief command to simply sib, use the alias exec sib show ip interface brief command.

R10(config)#alias exec sib show ip interface brief

R10#sib
Interface                  IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0         unassigned      YES unset  administratively down down
GigabitEthernet0/1         unassigned      YES unset  up                    up
GigabitEthernet0/1.102     172.19.102.10   YES NVRAM  up                    up
GigabitEthernet0/1.210     202.4.210.10    YES NVRAM  up                    up
Loopback0                  192.122.3.10    YES NVRAM  up                    up

To use the new alias on the command line, you must enter the complete syntax. Partial syntax for aliases is not accepted.


Cisco documentation: alias

Comments