- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
01-CLI commands | 140.31 KB |
Basic CLI commands
alias
Use alias to configure a command alias.
Use undo alias to delete a command alias.
Syntax
alias alias command
undo alias alias
Default
The device has a set of system-defined command aliases, as listed in Table 1.
Table 1 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 |
Views
System view
Predefined user roles
network-admin
Parameters
alias: Specifies an alias, a case-sensitive string of 1 to 20 characters. An alias cannot be alias or contain spaces.
command: Specifies a command string. Make sure the command string meets the syntax requirements.
Usage guidelines
System-defined command aliases cannot be deleted.
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 that start with display ip:
· Enter ship routing-table to execute the display ip routing-table command.
· Enter ship interface to execute the display ip interface command.
The command string can include up to 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 ip $1 | include $2 command. Then, to execute the display ip routing-table | include Static command, you only need to enter shinc routing-table Static. To execute the display ip interface | include Ten-GigabitEthernet1/0/1 command, you only need to enter shinc interface Ten-GigabitEthernet1/0/1.
Examples
# Configure shiprt as the alias for the display ip routing-table command and verify the configuration.
<Sysname> system-view
[Sysname] alias shiprt display ip routing-table
[Sysname] shiprt
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 Static 60 0 192.168.100.1 Vlan1
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.0.0/24 Direct 0 0 192.168.0.167 Vlan1
192.168.0.167/32 Direct 0 0 127.0.0.1 InLoop0
192.168.0.255/32 Direct 0 0 192.168.0.167 Vlan1
192.168.100.0/24 Direct 0 0 192.168.100.167 Vlan1
192.168.100.167/32 Direct 0 0 127.0.0.1 InLoop0
192.168.100.255/32 Direct 0 0 192.168.100.167 Vlan1
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
# Configure shinc as the alias for display ip $1 | include $2.
[Sysname] alias shinc display ip $1 | include $2
# Use alias shinc to display all static routes.
[Sysname] shinc routing-table Static
0.0.0.0/0 Static 60 0 192.168.100.1 Vlan1
Related commands
display alias
configuration reauthentication enable
Use configuration reauthentication enable to enable reauthentication for disruptive commands.
Use undo configuration reauthentication enable to disable reauthentication for disruptive commands.
Syntax
configuration reauthentication enable
undo configuration reauthentication enable
Default
Reauthentication for disruptive commands is disabled.
Views
System view
Predefined user roles
network-admin
Usage guidelines
Disruptive commands might power off or restart the device, interrupt services, cause service anomaly, delete key files, clear configuration, cause user login failure, or log off users, for example, the reboot command. Only the qualified professionals can execute disruptive commands.
As a best practice to avoid service failure caused by misoperations, enable reauthentication for disruptive commands.
The following rules apply after you enable reauthentication for disruptive commands:
· For a user that can log in to the device without authentication, reauthentication is not required when the user executes disruptive commands.
· For a user that logs in to the device after authentication, the user must enter the login password for authentication before disruptive commands are executed.
The undo configuration reauthentication command is also a disruptive command.
Examples
# Enable reauthentication for disruptive commands.
<Sysname> system-view
[Sysname] configuration reauthentication enable
# Reauthentication is required before you can execute the reboot command.
<Sysname> reboot
This command is disruptive or has significant impact on services. Please enter the login password again for reauthentication.
Password:
Start to check configuration with next startup configuration file, please wait.........DONE!
Current configuration will be lost after the reboot, save current configuration? [Y/N]:y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:y
Validating file. Please wait...
Configuration is saved to device successfully.
This command will reboot the device. Continue? [Y/N]:y
Now rebooting, please wait...
# Reauthentication is required before you can disable reauthentication for disruptive commands.
<Sysname> system-view
[Sysname] undo configuration reauthentication enable
This command is disruptive or has significant impact on services. Please enter the login password again for reauthentication.
Password:
[Sysname]
display | { count | { begin | exclude | include } }
Use display | { count | { begin | exclude | include } } to filter the output from a display command with a regular expression.
Syntax
display command [ | [ by-linenum ] [ [ after number ] [ before number ] | context number ] { count | { begin | exclude | include } regular-expression } ] &<1-128>
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
command: Specifies the keywords and arguments of a display command. To display available keywords and arguments, enter display ?.
by-linenum: Specifies the display information with line numbers.
after number: Displays the specified number of lines after the matching line, with a range of 1 to 100000.
before number: Displays the specified number of lines before the matching line, within a range of 1 to 100000.
context number: Displays the specified number of lines before and after the matching line, within a range of 1 to 100000.
begin: Displays the first line matching the specified regular expression and all subsequent lines.
exclude: Displays all lines not matching the specified regular expression.
include: Displays all lines matching the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
count: Displays the number of all lines in the output from a display command.
&<1-128>: Specifies a maximum of 128 filter conditions.
Usage guidelines
Use the | { begin | exclude | include } regular-expression option with a display command to filter the command output.
If a regular expression contains spaces, you can select whether to enclose the regular expression with double quotation marks, for example, display current-configuration | include interface A or display current-configuration | include "interface A".
The following rules apply when you specify regular expressions with or without double quotation marks:
· If a regular expression has double quotation marks, the string enclosed by double quotation marks is the filter condition.
· If a regular expression does not have double quotation marks, the string from the first non-space character to the last non-space character is the filter condition. The device uses this string as a filter condition for exact match of strings in the output from a display command.
· For example, regular-expression="interface A " and regular-expression=interface A are different filter conditions.
If a regular expression contains >, >, or > |, enclose the regular expression with double quotation marks (") to ensure that the device does not mistake these special characters for keywords.
If you specify multiple filter conditions, the system displays the output lines that meet all the conditions.
In a regular expression, the single quotation mark (') is treated as a special character. You can enclose a string in a pair of single quotation marks to match command output lines that contain that string. However, when you match command lines that contain single quotation marks, avoid including single quotation marks in the string to be matched.
For more information about regular expressions, see Fundamentals Configuration Guide.
When the begin, exclude, and include keywords are used in combination with the after and before keywords, follow the following restrictions:
· begin—If you specify after m before n, this command displays the lines matching the regular expression and the n lines before the line. The after m option is ineffective.
· exclude—If you specify after m before n, this command displays the lines that do not match the regular expression and the n lines before and m lines after the line.
· include—If you specify after m before n, this command displays the lines that match the regular expression and the n lines before and m lines after the line.
Examples
# Display the lines that contain vlan in the running configuration.
<Sysname> display current-configuration | include vlan
vlan 1
vlan 999
port access vlan 999
# Count the number of lines that contain alias in the running configuration.
<Sysname> display current-configuration | include alias | count
Total lines: 1.
# Display the lines that contain interface and TM in the running configuration.
<Sysname> display current-configuration | include interface | include TM
interface ATM2/0/17
interface ATM2/0/18
interface ATM2/0/19
interface ATM2/0/20
# Display the lines that contain interface TM in the running configuration.
<Sysname> display current-configuration | include interface ATM
interface ATM2/0/17
interface ATM2/0/18
interface ATM2/0/19
interface ATM2/0/20
display | by-linenum
Use display | by-linenum to number each output line for a display command.
Syntax
display command | by-linenum
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
command: Specifies the keywords and arguments of a display command. To display available keywords and arguments, enter display ?.
Usage guidelines
By numbering each output line from a display command, you can easily identify the lines of interest.
Each line number is displayed as a 5-character string and might be followed by a colon (:) or hyphen (-). If you specify both | by-linenum and | begin regular-expression for a display command, a hyphen is displayed for all lines that do not match the regular expression.
Examples
# Display VLAN 999 settings, with each output line identified by a number.
<Sysname> display vlan 999 | by-linenum
1: VLAN ID: 999
2: VLAN type: Static
3: Route interface: Configured
4: IPv4 address: 192.168.2.1
5: IPv4 subnet mask: 255.255.255.0
6: Description: For LAN Access
7: Name: VLAN 0999
8: Tagged ports: None
9: Untagged ports:
10: Ten-GigabitEthernet1/0/1
11:
# Display the first line that begins with user-group in the running configuration and all of the following lines.
<Sysname> display current-configuration | by-linenum begin user-group
114: user-group system
115- #
116- return
display >
Use display > to save the output from a display command to a separate file.
Syntax
display command > filename
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
command: Specifies the keywords and arguments of a display command. To display available keywords and arguments, enter display ?.
filename: Specifies the name of the file that is used to save the output, a string of 1 to 63 characters.
Usage guidelines
The display commands show the configuration, statistics, and states of the device. You can use the display > command to save the output to a file.
If the specified file does not exist, the system creates the file and saves the output to the file. If the file already exists, the system overwrites the file.
Examples
# Save VLAN 1 settings to a separate file named vlan.txt.
<Sysname> display vlan 1 > vlan.txt
# Check the content of the vlan.txt file.
<Sysname> more vlan.txt
VLAN ID: 1
VLAN type: Static
Route interface: Not configured
Description: VLAN 0001
Name: VLAN 0001
Tagged ports: None
Untagged ports:
GigabitEthernet1/0/2
Ten-GigabitEthernet1/0/1
VE-Bridge2
display >>
Use display >> to append the output from a display command to the end of a file.
Syntax
display command >> filename
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
command: Specifies the keywords and arguments of a display command. To display available keywords and arguments, enter display ?.
filename: Specifies the name of the file that is used to save the output, a string of 1 to 63 characters.
Usage guidelines
The display commands show the configuration, statistics, and states of the device. You can use display >> to save the output to a file.
If the specified file does not exist, the system creates the file and saves the output to the file. If the file already exists, the system appends the output to the end of the file.
Examples
# Append the VLAN 999 settings to the end of the vlan.txt file.
<Sysname> display vlan 999 >> vlan.txt
<Sysname>
# Check the content of the vlan.txt file.
<Sysname> more vlan.txt
VLAN ID: 1
VLAN type: Static
Route interface: Not configured
Description: VLAN 0001
Name: VLAN 0001
Tagged ports: None
Untagged ports:
GigabitEthernet1/0/2
Ten-GigabitEthernet1/0/1
VE-Bridge2
VLAN ID: 999
VLAN type: Static
Route interface: Configured
IPv4 address: 192.168.2.1
IPv4 subnet mask: 255.255.255.0
Description: For LAN Access
Name: VLAN 0999
Tagged ports: None
Untagged ports:
GigabitEthernet1/0/2
Ten-GigabitEthernet1/0/1
VE-Bridge2
display alias
Use display alias to display command aliases.
Syntax
display alias [ alias ]
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
alias: Specifies a command alias. If you do not specify this argument, the command displays all command aliases.
Examples
# Display all command aliases.
<Sysname> display alias
Index Alias Command key
1 access-list acl
2 end return
3 erase delete
4 exit quit
5 hostname sysname
6 logging info-center
7 no undo
8 shinc display $1 | include $2
9 show display
10 sirt display ip routing-table
11 write save
# Display the command alias shinc.
<Sysname> display alias shinc
Alias Command key
shinc display ip $1 | include $2
Related commands
alias
display history-command
Use display history-command to display all commands that are saved in the command history buffer for the current CLI session.
Syntax
display history-command
Views
Any view
Predefined user roles
network-admin
network-operator
Usage guidelines
The system automatically saves commands you have successfully executed to the command history buffer for the current CLI session. You can view them and execute them again.
By default, the system can save up to 10 commands in the buffer. You can use the history-command max-size command to change the buffer size. To buffer a new command when the buffer is full, the system deletes the oldest command entry in the buffer.
All commands in the command history buffer for the current CLI session will be cleared when you log out.
The system displays passwords as asterisks (*) to ensure device security if the command history buffer has password configuration commands.
Examples
# Display all commands saved in the command history buffer for the current CLI session.
<Sysname> display history-command
system-view
vlan 2
quit
Related commands
history-command max-size
display history-command all
Use display history-command all to display all commands that are saved in the command history buffer for all CLI sessions.
Syntax
display history-command all
Views
Any view
Predefined user roles
network-admin
Usage guidelines
The system automatically saves commands successfully executed by users to the command history buffer for all CLI sessions. Users can view them but cannot recall them from the buffer.
Up to 1024 commands can be saved in the command history buffer. To buffer a new command when the buffer is full, the system deletes the oldest command entry in the buffer.
A user logout does not cause the system to delete commands from the history buffer for all CLI sessions.
The system displays passwords as asterisks (*) to ensure device security if the command history buffer has password configuration commands.
Examples
# Display all commands saved in the command history buffer for all CLI sessions.
<Sysname> display history-command all
Date Time Terminal Ip User
03/16/2017 20:03:33 vty0 192.168.1.26 **
Cmd:dis his all
03/16/2017 20:03:29 vty0 192.168.1.26 **
Cmd:sys
Table 2 Command output
Field |
Description |
Date |
Date when the command was executed. |
Time |
Time when the command was executed. |
Terminal |
User line used by the user. |
Ip |
IP address of the terminal used by the user. |
User |
Username used by the user if the user login authentication mode is scheme. If the login authentication mode is none or password, this field displays **. |
Cmd |
Command string entered by the user. |
Related commands
display hotkey
Use display hotkey to display hotkey information.
Syntax
display hotkey
Views
Any view
Predefined user roles
network-admin
network-operator
Examples
# Display hotkey information.
<Sysname> display hotkey
----------------- Hotkeys -----------------
-Defined command hotkeys-
CTRL_G display current-configuration
CTRL_L display ip routing-table
CTRL_O undo debugging all
-Undefined command hotkeys-
CTRL_T NULL
CTRL_U NULL
-System-reserved hotkeys-
CTRL_A Move the cursor to the beginning of the line.
CTRL_B Move the cursor one character to the left.
CTRL_C Stop the current command.
CTRL_D Erase the character at the cursor.
CTRL_E Move the cursor to the end of the line.
CTRL_F Move the cursor one character to the right.
CTRL_H Erase the character to the left of the cursor.
CTRL_K Abort the connection request.
CTRL_N Display the next command in the history buffer.
CTRL_P Display the previous command in the history buffer.
CTRL_R Redisplay the current line.
CTRL_V Paste text from the clipboard.
CTRL_W Delete the word to the left of the cursor.
CTRL_X Delete all characters from the beginning of the line to the cursor.
CTRL_Y Delete all characters from the cursor to the end of the line.
CTRL_Z Return to the User View.
CTRL_] Kill incoming connection or redirect connection.
ESC_B Move the cursor back one word.
ESC_D Delete all characters from the cursor to the end of the word.
ESC_F Move the cursor forward one word.
ESC_N Move the cursor down a line.
ESC_P Move the cursor up a line.
ESC_< Move the cursor to the beginning of the clipboard.
ESC_> Move the cursor to the end of the clipboard.
Table 3 Command output
Field |
Description |
CTRL_] |
Terminates the current connection. |
ESC_D |
Deletes all characters from the cursor to the end of the word. |
ESC_N |
Moves the cursor down a line. |
ESC_P |
Moves the cursor up a line. |
ESC_< |
Moves the cursor to the beginning of the clipboard. |
ESC_> |
Moves the cursor to the end of the clipboard. |
|
NOTE: If the next or previous command in the command history buffer is a password configuration command, the Ctrl+N or Ctrl+P hotkey skips the command. |
Related commands
hotkey
hotkey
Use hotkey to assign a command to a configurable command hotkey.
Use undo hotkey to restore the default.
Syntax
hotkey { ctrl_g | ctrl_l | ctrl_o | ctrl_t | ctrl_u } command
undo hotkey { ctrl_g | ctrl_l | ctrl_o | ctrl_t | ctrl_u }
Default
· Ctrl+G: display current-configuration (display the running configuration).
· Ctrl+L: display ip routing-table (display the IPv4 routing table information).
· Ctrl+O: undo debugging all (disable all debugging functions).
· Ctrl+T: No command is assigned to this hotkey.
· Ctrl+U: No command is assigned to this hotkey.
Views
System view
Predefined user roles
network-admin
Parameters
ctrl_g: Assigns a command to Ctrl+G.
ctrl_l: Assigns a command to Ctrl+L.
ctrl_o: Assigns a command to Ctrl+O.
ctrl_t: Assigns a command to Ctrl+T.
ctrl_u: Assigns a command to Ctrl+U.
command: Specifies the command to be assigned to the hotkey.
Usage guidelines
The system defines some hotkeys and provides five configurable command hotkeys. Pressing a command hotkey executes the command assigned to the hotkey.
To display system-defined and configurable hotkeys, use the display hotkey command.
Examples
# Assign the display tcp statistics command to hotkey Ctrl+T.
<Sysname> system-view
[Sysname] hotkey ctrl_t display tcp statistics
Related commands
display hotkey
quit
Use quit to return to the upper-level view.
Syntax
quit
Views
Any view
Predefined user roles
network-admin
network-operator
Usage guidelines
Executing this command in user view disconnects you from the device.
Examples
# Return from Ten-GigabitEthernet 1/0/1 interface view to system view and then to user view.
[Sysname-Ten-GigabitEthernet1/0/1] quit
[Sysname] quit
<Sysname>
repeat
Use repeat to repeat commands in the command history buffer for the current CLI session.
Syntax
repeat [ number ] [ count times ] [ delay seconds ]
Views
Any view
Predefined user roles
network-admin
Parameters
number: Specifies the number of the most recently executed commands in the command history buffer for the current CLI session that you want to execute. The value range is 1 to 256. The default is 1.
count times: Specifies the number of times that you want to execute the commands. The value range is 0 to 4294967295. The default is 0. If you do not specify this option, the system keeps executing the commands until you press the escape key to terminate the execution.
delay seconds: Specifies the time (in seconds) for the system to wait before executing the commands again. The value range is 0 to 4294967295. The default is 1.
Usage guidelines
To repeat a command, first enter the view for the command. To repeat multiple commands, first enter the view for the first command.
The repeat command executes commands in the order they were executed.
The system waits for your interaction when it repeats an interactive command.
The system skips all password configuration commands.
The number of commands to be repeated in the command history buffer is determined by the minimum value of the following:
· Number of the most recently executed commands in the command history buffer specified by the repeat command.
· Size of the command history buffer specified by the history-command max-size command.
· Number of the commands in the command history buffer.
Examples
# Configure the system to execute the two most recently executed commands (display cpu-usage and display clock) three times at an interval of 10 seconds.
<Sysname> repeat 2 count 3 delay 10
<Sysname> display cpu
Unit CPU usage:
33% in last 5 seconds
32% in last 1 minute
33% in last 5 minutes
<Sysname> display clock
07:02:18 UTC Thu 06/19/2017
<Sysname> display cpu-usage
Unit CPU usage:
33% in last 5 seconds
32% in last 1 minute
33% in last 5 minutes
<Sysname> display clock
07:02:28 UTC Thu 06/19/2017
<Sysname> display cpu-usage
Unit CPU usage:
33% in last 5 seconds
32% in last 1 minute
33% in last 5 minutes
<Sysname> display clock
07:02:38 UTC Thu 06/19/2017
Related commands
display history-command
escape-key
history-command max-size
return
Use return to return to user view from any other view except Tcl configuration view.
Syntax
return
Views
Any view except user view and Tcl configuration view
Predefined user roles
network-admin
network-operator
Usage guidelines
In any view except user view and Tcl configuration view, pressing Ctrl+Z has the same effect as the return command.
To return to user view from Tcl configuration view, use the tclquit command.
Examples
# Return to user view from Ten-GigabitEthernet 1/0/1 interface view.
[Sysname-Ten-GigabitEthernet1/0/1] return
<Sysname>
screen-length disable
Use screen-length disable to disable pausing between screens of output for the current CLI session.
Use undo screen-length disable to enable pausing between screens of output for the current CLI session.
Syntax
screen-length disable
undo screen-length disable
Default
The default depends on the configuration of the screen-length command in user line view.
The following are the default settings for the screen-length command:
· Pausing between screens of output.
· Displaying up to 24 lines on a screen.
Views
User view
Predefined user roles
network-admin
Usage guidelines
If you disable pausing between screens of output, all output is displayed. The screen is refreshed continuously until the final screen is displayed.
This command takes effect only for the current CLI session. When you are logged out, the default is restored.
Examples
# Disable pausing between screens of output for the current CLI session.
<Sysname> screen-length disable
Related commands
screen-length
system-view
Use system-view to enter system view from user view.
Syntax
system-view
Views
User view
Predefined user roles
network-admin
network-operator
Examples
# Enter system view from user view.
<Sysname> system-view
System View: return to User View with Ctrl+Z.
[Sysname]