Enter commands more efficiently with Cisco command aliases
Takeaway: Over time, constantly entering commands on Cisco routers and switches can become uncomfortably tedious. To make life easier, Cisco offers the alias command, which can help dispel part of this repetition. David Davis introduces you to the alias command and discusses some of his favorite uses of this handy command.
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.
Print/View all Posts Comments on this article
|
|
|
|
|
|
|
|
|
|
|
|
|
|
White Papers, Webcasts, and Downloads
- Volume Activation Improvements in Windows 7 Microsoft With the release of the Windows 7 Operating System, Microsoft has ... Download Now
- Unified Communications and Your Business: What You Need to Know Qwest Communications Get an overview of the potential benefits of Unified Communications (UC), including key considerations for mapping out your UC strategy. Download Now
- Smarter Products: The Building Blocks for a Smarter Planet IBM Corp. Businesses are delivering a new generation of smarter products that are ... Download Now
- Webinar: Best Practices for Application Virtualization with AdminStudio Flexera Software IT professionals, are you considering a move to Microsoft? App-V?? Watch ... Download Now
- Recession Proofing Your Organization with Electronic Forms IBM Corp. The current economy is forcing organizations of all sizes to look more ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET
