Tuesday, July 17, 2007

Cisco Command Aliases

Alias command allows you to define aliases for long commands. Alias command breaks down into three modes:

Alias Exec for Privileged Mode.
Alias Configure for Global Configuration Mode.
Alias Interface for Interface Configuration Mode.

Let say that you want to shorten Show Running-Configuration command to just two keystrokes, you could define it as follow:

Router(Config)# alias exec sr Show Running-config

Or if you want to use ns to perform No Shut command on an interface you could define it as:

Router(Config)# alias interface ns no shutdown

So now instead of typing out all those long commands you could type sr for show runn or ns for no shut down and still achieve the same desired effects.

Cisco IOS includes some built-in command aliases. You can view these aliases by using the "show alias" command. Here are the default command aliases:
  • h - help
  • lo - logout
  • p - ping
  • r - resume
  • s - show
  • u - undebug
  • un - undebug
  • w - where
The Alias Command reminds me of the .bat files back in the DOS days when we used it to combine multiple commands together and shorten the filename to just a few keystrokes. If used effectively, this could saving you a lot of time and typing.


Anonymous said...

Is there any way to incorporate two separate commands into one alias statement? I am trying to ensure the validity of a config backup.

alias exec buc wr mem copy start tftp://xx.xx.xx.xx/filename,

where the two commands wr mem and the copy command need to be in one alias construct (obviously the above does not work nor does delimiting by ;). The xx.xx.xx.xx is the tftp server ip, of course.

Anonymous said...

yeah... interesting style :))