In response to my recent article about filtering Cisco
router command output
, a TechRepublic member posted to the article’s discussion
about another way to deal with commands more effectively. Beau explained how he uses
Cisco IOS aliases
to save time and keystrokes on repetitive Cisco IOS
commands.

“So the / filtering was new to me. Good to know, but I
usually just use include/begin/exclude to get to what I need. To make these
even easier, I set up aliases:

srb - Show Running-Config | Begin
sre - Show Running-Config | Exclude
sri - Show Running-Config | Include
srint - Show Running-Config Interface"

This member makes an excellent point about how useful and
timesaving command aliases can be. I’ve used command aliases both when taking
CCIE lab exams and in the real world on production routers.

Over time, constantly entering commands on Cisco routers and
switches can become uncomfortably repetitive. In fact, a network administrator
frequently must type the same command over and over again. To make life easier,
Cisco offers the alias command, which
can help dispel part of this repetition.

Let’s take a closer look at the alias command. This is a Global Configuration command. To use it,
enter the alias command and identify which
privilege level you want to specify the alias for. Here are some examples:

  • Use alias
    exec
    for Privileged Mode (any command you use at the router# prompt).
  • Use alias
    configure
    for Global Configuration Mode (any command you
    use at the router(config)#
    prompt).
  • Use alias
    interface
    for Interface Configuration Mode (any command you use
    at the router(config-if)# prompt).

After specifying the privilege level, enter the alias you
want to create and the command you want it to stand for.

As far as I know, you can configure an alias to do anything
that you can do at the command line. Of course, there’s a catch: An alias can’t
move between modes, type in passwords, or do anything interactive for you.

Alias examples

Let’s look at some examples of using the alias command. Let’s start off by
demonstrating how to configure the alias
commands that TechRepublic member Beau
suggested. Below are the aliases and the necessary command to create that
alias:

srb - Show Running-Config | Begin
Router(config)# alias exec srb show running-config | begin
sre - Show Running-Config | Exclude
Router(config)# alias exec sre show running-config | exclude
sri - Show Running-Config | Include
Router(config)# alias exec sri show running-config | include
srint - Show Running-Config Interface
Router(config)# alias exec srint show running-config interface

From these examples, you can see that the aliases you create
don’t have to be complete commands. You can specify parameters for a command
after entering the alias.

For example, to use the shortcut for the show running-config interface command—srint—you can specify the interface for
which you want to view configuration information after that command. Here’s an
example:

srint fa0/0

Default aliases

Did you know that the Cisco IOS includes some built-in command
aliases? (Of course, the Cisco IOS always accepts the shortest unique command,
but I’m talking about real command aliases.) Here are the default command
aliases:

  • p stands for ping.
  • h stands for help.
  • lo stands for logout.
  • u and un stand for undebug.
  • w stands for where.

You can view these aliases by using the show alias command—whether you’ve actually configured any aliases of
your own.

Critic’s choice

Here are some of my personal favorite aliases, along with
the commands to configure them:

Alias: s
Short for: show running-configuration
Create it with: alias exec s sh run
Alias: c
Short for: configure terminal
Create it with: alias exec c conf t
Alias: sir
Short for: show ip route
Create it with: alias exec sir sh ip ro

You can use the above alias to specify parameters, such as sir bor sir o, to show all BGP routes or all OSPF routes. Or, to see a
specific route, you could use sir 10.1.1.1.

Alias: i
Short for: show ip interface brief
Create it with: alias exec i sh ip int brie

When using frame relay, you can use aliases like the
following:

Alias: pvc
Short for: show frame-relay pvc
Create it with: alias exec pvc show fram pvc
Alias: dwn
Short for: show frame-relay map | include down
Create it with: alias exec dwn sh fram map | inc down

If you go into a certain router configuration a lot (for
example, BGP AS 1234), you can use the following:

Alias: b
Short for: router bgp 1234
Create it with: alias configure b router bgp 1234

If you often have to use the no shutdown command on an interface, you can use this alias:

Alias: ns
Short for: no shutdown
Create it with: alias interface ns no shutdown

The possibilities for creating command aliases are
unlimited. What are your favorite command aliases? Post them in this article’s
discussion.

Miss a column?

Check out the Cisco Routers and Switches
Archive
, and catch up on David Davis’ most recent columns.

Want to learn more
about router and switch management? Automatically
sign up for our free Cisco Routers and Switches newsletter
, delivered each
Friday!

David Davis has worked
in the IT industry for 12 years and holds several certifications, including
CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of
systems/network administrators for a privately owned retail company and
performs networking/systems consulting on a part-time basis.