As a network admin, typing the same commands over and over can get tedious. With the use of aliases, you can get more done in less time. Let's examine some of the most popular CLI (command line interfaces) and how they implement aliasing.
Cisco IOS
Cisco routers and switches running IOS (not CatOS) implement the alias exec command. Here are some examples:
show ip route
alias exec sir show route
show ip interface brief
alias exec siib show ip interface brief
configure terminal
alias exec ct config term
show running-config
alias exec sr show running
copy running-config startup-config
alias exec cp copy running start
Equivalent of a Linux grep command
alias exec g show running-config | i
show CPU processes and exclude all those with 0% usage:
alias exec cpu sh proc cpu | e 0.00%
Cisco ASA Firewall
Cisco ASA Firewalls implement the command-alias command to enable you to create aliases.
show running-config
command-alias exec sr show running
configure terminal
command-alias exec ct config term
show interface ip brief (notice the inversion here compared with its IOS cousin)
command-alias exec siib show int ip brie
show ip route
command-alias exec sir sh route
Equivalent of a Linux grep command
command-alias exec g show running-config | i
show vpn session database detail for LAN-to-LAN
command-alias exec vpnl show vpn-sessiondb detail l2l
show vpn session database with full index
command-alias exec vpnf show vpn-sessiondb detail full index 1
Linux / Unix /Mac OS X
Mac OS X and the *nixes of this world all have different kind of shells. The one I use is BASH shell. I store all my favorite aliases in a hidden file called .bashrc which get read at shell creation. Here is some of them:
clear the display
alias k='clear'
Issue the ping command
alias p='ping'
Issue the traceroute command
alias t='traceroute'
List the directory, long form
alias ll='ls -l'
List the directory, long form and pause
alias llm='ls -l | more'
List the directory, long form with the most recent entries first and pause
alias lltm='ls -lt | more'
Windows Command Shell
Under Microsoft Windows, you can implement something similar to aliases with the doskey command. You can store all of these in a batch file which gets executed at startup. Then, execute the cmd.exe command to start a command shell and type your aliases when needed. Here is a few examples:
Clear the display
doskey k=cls
Display your IP address
doskey ip=ipconfig /all
Display the running processes
doskey pef=tasklist
Find a specific process among the running processes, e.g., peff cmd.exe
doskey peff=tasklist $b findstr /i $1
Display the running services
doskey svc=sc query
Find a specific service among the running services
doskey svcc=sc query $b findstr /i "$1"
Stop a running process, e.g., ki word.exe
doskey ki=wmic process where name="$1" delete
Equivalent of a Linux grep command
doskey g=findstr /i "$1"
Exit the command shell
doskey q=exit
TextExpander
You can also use TextExpander and set your aliases in there instead of configuring your network gear with them. This tool enables you to have a portable set of aliases on your MacBook. Some CLI interfaces do not support aliases, I am thinking to Cisco WLC (Wireless LAN Controller). If you do lots of WLC CLI stuff, you could save keystrokes by using TextExpander.