Cisco – How to speed up CLI typing in Cisco IOS using shortcuts

ciscocisco-commandscisco-ioscli

I know we can use auto-completion (tab key) and abbreviated commands (such as sh ip int bri) to speed up typing.

However, I'm still not satisfied with typing crypting chains such as sh ip dh sn bi | i 20.12 for show ip dhcp snooping binding | include 20.12.

Can I define shortcuts for often used command sequences, and how?

Best Answer

We can use the alias command in global conf mode:

alias <mode> <command-alias> <original-command>

<mode> is one of the many IOS command modes. If you need it in different modes, you have to call it for each one - type alias ? to get a long list of modes.

An example for checking for a dhcp snooped IP, type in global conf mode

alias exec snoop show ip dhcp snooping binding | include

Now you can simply type snoop 172.16.20.12 to check for this IP or snoop 801 for checking all IPs in VLAN 801, for example. Do similarly for show mac-address-table | include and you're faster in searching and troubleshooting.

Further tipps:

  • document your aliases for you and for your collegues
  • sh aliases shows your aliases plus the predefined ones
  • while no alias <mode> <command> can be guessed for removing an alias, no alias <mode> deletes the aliases for a complete mode - so you can clear several at once, default alias <mode> works similarly, as expected
  • if you decide to use aliases, deploy them once everywhere you may need them
  • tools like Cisco Prime can help in deploying
  • don't forget the original commands ;-)
Related Topic