Configuring and using command aliases

You can configure one or more aliases for a command or the starting keywords of commands. Then, you can use the aliases to execute the command or commands. If the command or commands have undo forms, you can also use the aliases to execute the undo command or commands.

For example, if you configure the alias shiprt for display ip routing-table, you can enter shiprt to execute the display ip routing-table command. If you configure the alias ship for display ip, you can use ship to execute all commands starting with display ip:

Usage guidelines

After you successfully execute a command by using an alias, the system saves the command, instead of the alias, to the running configuration.

The command string represented by an alias can include a maximum of nine parameters. Each parameter starts with the dollar sign ($) and a sequence number in the range of 1 to 9. For example, you can configure the alias shinc for the display $1 | include $2 command. Then, you can enter shinc hotkey CTRL_C to execute the display hotkey | include CTRL_C command.

To use an alias for a command that has parameters, you must specify a value for each parameter. If you fail to do so, the system informs you that the command is incomplete and displays the command string represented by the alias.

The device has a set of system-defined command aliases, as listed in Table 3. System-defined command aliases cannot be deleted.

Table 3: System-defined command aliases

Command alias

Command or command keyword

access-list

acl

end

return

erase

delete

exit

quit

hostname

sysname

logging

info-center

no

undo

show

display

write

save

Configuration procedure

To configure a command alias:

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Configure a command alias.

alias alias command

By default, the device has a set of command aliases, as listed in Table 3.

3. (Optional.) Display command aliases.

display alias [ alias ]

This command is available in any view.