alias
Syntax
alias <ALIAS-NAME> <COMMAND-STRING>
no alias <ALIAS-NAME>
Description
Defines an alias for one or more CLI commands. The alias and its definition are valid only for the user that creates the alias.
The
no
form of this command removes the specified alias.
Command context
config
Parameters
<ALIAS-NAME>
Specifies the name of the alias you are defining.
<COMMAND-STRING>
Specifies one or more commands and their parameters. Separate commands with a semicolon (;). Length: 1 to 400 characters.
For commands that require user-supplied parameters, use
$1
through$n
, in order, as placeholders. These parameters are replaced by the corresponding arguments from the command line, and must match the number of parameters required by the original command. For alias definitions that include multiple commands, continue numbering parameters through all commands. Do not restart numbering for each command.
Authority
Administrators or local user group members with execution rights for this command.
Examples
Creating the alias hst for the hostname command. The hostname command has a single argument, therefore $1 is required to support it.
switch(config)# alias hst hostname $1
Using the
show alias
command to show all the aliases that are defined on the switch.
switch(config)# do show alias Alias Name Alias Definition ------------------------------------------------------------------------ hst hostname $1
Using the new hat alias command:
switch(config)# hst myhost myhost(config)#
Example alias defined by multiple commands
Configuring the alias intf_config for the commands interface, no shutdown, ip address, and lldp receive with supported parameters:
alias intf_config interface $1; no shutdown; ip address $2; lldp receive; mtu $3; exit
Executing the
intf_config
alias command:
switch(config)# intf_config 1/1/1 10.0.0.1/24 1200