Professional Documents
Culture Documents
01-01 CLI Overview
01-01 CLI Overview
Ethernet Switches
Configuration Guide - Basic Configuration 1 CLI Overview
1 CLI Overview
User view When a user logs in to In the user view, you can
the device, the user view the running status
enters the user view and and statistics of the
the following prompt is device.
displayed:
<HUAWEI>
The command line prompt HUAWEI is the default host name (sysname). The
prompt indicates the current view. For example, <> indicates the user view and []
indicates all other views except the user view.
You can enter ! or # followed by a character string in any view. All the entered
content (including ! and #) is displayed as comments and no corresponding
configuration will be generated.
NOTE
● Some commands can be executed in multiple views, but they have different functions
when being executed in different views. For example, you can run the lldp enable
command in the system view to enable LLDP globally and in the interface view to
enable LLDP on an interface.
● In the system view, you can run the diagnose command to enter the diagnostic view.
Diagnostic commands are used for device fault diagnosis. If you run some commands in
the diagnostic view, the device may fail to run properly or services may be interrupted.
Contact technical support personnel and use these diagnostic commands with caution.
● You can enter ! or # followed by a character string in any view. All the entered content
(including ! and #) is displayed as comments and can be properly. That is, no error
message is displayed and no the corresponding configuration is not generated.
● After you enter the CLI command and press Enter, the command is executed
immediately within 5 seconds.
For example, you can run the quit command to return from the AAA view to the
system view. You can then run the quit command again to return from the system
view to the user view.
[HUAWEI-aaa] quit
[HUAWEI] quit
<HUAWEI>
To return from the AAA view directly to the user view, press Ctrl+Z or run the
return command.
Intelligent Rollback
Intelligent rollback, by default, enables the system to automatically return to the
previous view if a command fails to be executed in the current view. The system
continues to attempt to return to the required view until it returns to the system
view. If you want to disable the intelligent rollback function, run the undo
terminal command forward matched upper-view command. This command is
valid only for the current login user who runs this command.
NOTE
Intelligent rollback cannot be performed in the port group view and VLAN-Range view.
If command matching fails because an ambiguous command is entered in the current view,
no intelligent rollback can be performed.
If the intelligent rollback function is enabled, commands may be executed in unexpected
views, and services may be interrupted. Before configuring a command, check whether the
command to be configured exists in the view. If the command does not exist, run the
command in the correct view.
The following provides two application examples for intelligent rollback. The
system enters the applicable view of a command after performing one view return
attempt in the first example, and performs multiple attempts in the second
example.
1. After entering an OSPF area view, the system allows a user to directly enter
another OSPF area view, without the need to manually return to the OSPF
view.
<HUAWEI> system-view
[HUAWEI] ospf 100
[HUAWEI-ospf-100] area 1
[HUAWEI-ospf-100-area-0.0.0.1] area 2
[HUAWEI-ospf-100-area-0.0.0.2]
2. After entering an OSPF area view, the system allows a user to directly enter
an interface view, without the need to manually return to the system view.
<HUAWEI> system-view
[HUAWEI] ospf 100
[HUAWEI-ospf-100] area 1
[HUAWEI-ospf-100-area-0.0.0.1] interface gigabitEthernet 0/0/3
[HUAWEI-GigabitEthernet0/0/3]
Backspace Deletes the character on the left of the cursor and the
cursor moves to the left. When the cursor reaches the
head of the command, an alarm is generated.
Left cursor key ← or Moves the cursor to the left by the space of a
Ctrl+B character. When the cursor reaches the head of the
command, an alarm is generated.
Right cursor key → or Moves the cursor to the right by the space of a
Ctrl+F character. When the cursor reaches the end of the
command, an alarm is generated.
Operating Techniques
Incomplete Keyword
You can enter incomplete keywords on the device. In the current view, you do not
need to enter complete keywords if the entered characters can match a unique
keyword. This function improves operating efficiency.
NOTICE
Tab
b. Press Tab.
The system replaces the entered keyword and displays it in a new line
with the complete keyword followed by a space.
[HUAWEI] info-center
● When the input has multiple matches, press Tab repeatedly to display the
keywords beginning with the incomplete input in a circle until the desired
keyword is displayed. In this case, the cursor closely follows the end of the
keyword. For example:
a. Enter an incomplete keyword.
[HUAWEI] info-center log
b. Press Tab.
The system displays the prefixes of all the matched keywords. In this
example, the prefix is log.
[HUAWEI] info-center loghost
Press Tab to switch from one matched keyword to another. In this case,
the cursor closely follows the end of a word.
[HUAWEI] info-center logbuffer
b. Press Tab.
[HUAWEI] info-center loglog
The system displays information in a new line, but the keyword loglog
remains unchanged and there is no space between the cursor and the
keyword. This indicates that this keyword does not exist.
Full Help
When entering a command, you can use the full help function to obtain keywords
and parameters for the command. Use any of the following methods to obtain full
help from a command line.
● Enter a question mark (?) in any command view to obtain all the commands
and their simple descriptions. For example:
<HUAWEI> ?
User view commands:
backup Backup electronic elabel
cd Change current directory
check Check information
clear Clear information
clock Specify the system clock
compare Compare function
...
Partial Help
If you enter only the first or first several characters of a command keyword, partial
help provides keywords that begin with this character or character string. Use any
of the following methods to obtain partial help from a command line.
● Enter a character string followed directly by a question mark (?) to display all
keywords that begin with this character string. For example:
<HUAWEI> d?
debugging delete dir display
<HUAWEI> d
● Enter the first several letters of a keyword in a command and press Tab to
display a complete keyword. The first several letters, however, must uniquely
identify the keyword. If they do not identify a specific keyword, press Tab
continuously to display different keywords and you can select one as required.
NOTE
The command output obtained through the online help function is used for reference only.
Log out of the device and re-log in. A message "Hello,Welcome to Huawei!" is
displayed before user authentication. Run the undo header login command.
Hello,Welcome to Huawei!
Login authentication
Password:
Info: The max number of VTY users is 20, and the number
of current VTY users on line is 5.
The current login time is 2012-06-09 04:46:00.
<HUAWEI> system-view
[HUAWEI] undo header login
Log out of the terminal and re-log in. No message is displayed before
authentication.
Login authentication
Password:
Info: The max number of VTY users is 20, and the number
of current VTY users on line is 5.
The current login time is 2012-06-09 04:52:10.
<HUAWEI>
NOTE
The command output provided here is used for reference only. The actual output
information may differ from the preceding information.
Context
Manual mode batch command execution is available. A user edits commands to
be executed in batches and saves the commands in the device memory. When the
user performs batch command execution, the device reads the commands from
the memory, executes them one by one, and returns the execution result.
Assistant tasks help implement automatic batch command execution. You can
create a maximum of five assistant tasks on the device and each assistant task is
bound with a batch file. After an execution time is configured, the device
automatically executes commands in the batch file one by one. Automatic batch
command execution is frequently used for periodic system upgrade or
configuration.
A batch file is a collection of executable commands and the file is in the format of
*.bat. When the batch file is processed, commands in the file are executed one by
one.
Pre-configuration Tasks
Before configuring automatic batch command execution, perform the following
tasks:
If the file name extension is not .bat, change it to .bat before you upload the batch file to
the device. Alternatively, upload the batch file to the device and then run the rename
command to change the file name extension.
Procedure
1. Run the system-view command to enter the system view.
2. Run the assistant task task-name command to create an assistant task.
3. Run the if-match timer cron seconds minutes hours days-of-month months
days-of-week [ years ] command to specify the time for performing assistant
tasks.
4. Run the perform priority batch-file filename command to bind the batch file
with the assistant task.
5. Run the display assistant task history [ task-name ] command to check the
operation records of assistant tasks.
Procedure
Step 1 Run run command-line
The parameter command-line is a user view command. You must enter the
complete command manually because automatic command line completion is not
supported.
----End
NOTE
The terminal in use may affect the functions of the shortcut keys because the shortcut keys
entered by the user are captured by the terminal program. For example, if the shortcut keys
defined by the terminal conflict with those defined in the system, the commands
corresponding to the shortcut keys are not executed.
Key Function
Key Function
A simple regular expression does not contain any special character. For
example, you can create a simple regular expression "hello" to match the
character string "hello" only. In practice, multiple common and special
characters are used together to match a character string with special features.
● Degeneration of special characters
Certain special characters, when placed at certain positions in a regular
expression, degenerate to common characters.
– The special characters following "\" match special characters themselves.
– The special characters "*", "+", and "?" are placed at the starting position
of the regular expression. For example, +45 matches "+45" and abc(*def)
matches "abc*def".
– The special character "^" is placed at any position except for the start of
the regular expression. For example, abc^ matches "abc^".
– The special character "$" is placed at any position except for the end of
the regular expression. For example, 12$2 matches "12$2".
– A right parenthesis ")" or right bracket "]" is not paired with a
corresponding left parenthesis "(" or bracket "[". For example, abc)
matches "abc)" and 0-9] matches "0-9]".
NOTE
Unless otherwise specified, degeneration rules also apply when the preceding regular
expressions are subexpressions within parentheses.
NOTICE
The switch uses a regular expression to implement the pipe character filtering
function. A display command supports the pipe character only when there is
excessive output information.
If a large amount of information needs to be displayed, it takes a long time for
the system to obtain the filtered information correctly.
There are two modes to filter output information based on the regular expression.
● Specifying a filtering mode in a command: enter the keyword begin, exclude,
or include, and a regular expression in the command line to filter command
outputs.
● Specifying a filtering mode on a split screen: enter a slash (/), minus (-), or
plus (+) symbol, and a regular expression to filter command outputs to be
displayed on a split screen. The slash (/), minus (-), and plus (+) symbols have
the same functions as the keywords begin, exclude, and include.
Some commands can carry the parameter | count to display the number of
matching entries. The parameter | count can be used together with other
parameters.
Three filtering modes are provided for commands that support regular
expressions.
● | begin regular-expression: displays all the lines beginning with the line that
matches the regular expression.
Filter the character strings to be entered until the specified case-sensitive
character string is displayed. All the character strings following this specified
character string are displayed on the screen.
● | exclude regular-expression: displays all the lines that do not match the
regular expression.
If the character strings to be entered do not contain the specified case-
sensitive character string, they are displayed on the screen. Otherwise, they
are filtered.
● | include regular-expression: displays all the lines that match the regular
expression.
If the character strings to be entered contain the specified case-sensitive
character string, they are displayed on the screen. Otherwise, they are filtered.
The value of regular-expression is a string of 1 to 255 characters.
NOTE
You can specify the filtering mode of output information for some display commands that
have a large amount of output information.
After the command output is filtered, the displayed information is displayed with
its context. Context rules are as follows:
● before before-line-number: displays lines that match filtering rules and the
preceding before-line-number lines.
● after after-line-number: displays lines that match filtering rules and the
subsequent after-line-number lines.
● before before-line-number + after after-line-number or after after-line-
number + before before-line-number: displays lines that match filtering rules,
the preceding before-line-number lines, and the subsequent after-line-number
lines.
Values of before-line-number and after-line-number are integers in the range
1 to 999.
The following examples describe how to specify a filtering mode in a command.
Example 1: Run the display interface brief command to display all the lines that
do not match Ethernet, NULL, or Tunnel.
<HUAWEI> display interface brief | exclude Ethernet|NULL|Tunnel
PHY: Physical
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(d): Dampening Suppressed
InUti/OutUti: input utility/output utility
Interface PHY Protocol InUti OutUti inErrors outErrors
Eth-Trunk1 down down 0% 0% 0 0
Eth-Trunk17 down down 0% 0% 0 0
LoopBack1 up up(s) 0% 0% 0 0
Vlanif1 up down -- -- 0 0
MEth0/0/1 down down 0% 0% 0 0
Vlanif2 down down -- -- 0 0
Vlanif10 down down -- -- 0 0
Vlanif12 down down -- -- 0 0
Vlanif13 down down -- -- 0 0
Vlanif20 up up -- -- 0 0
Vlanif22 down down -- -- 0 0
Vlanif222 down down -- -- 0 0
Vlanif4094 down down -- -- 0 0
Example 3: after is used to output the lines that meet the filtering rules and the
corresponding data information. (The usage of before is the same.)
<HUAWEI> display ip routing-table | after 2 include
0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 16 Routes : 16
NOTE
The command output provided here is used for reference only. The actual output
information may differ from the preceding information.
#
dhcp snooping enable
+Vlanif //Enter the filtering mode.
Filtering...
interface Vlanif10
interface Vlanif100
Table 1-5 Relations between command privilege levels and user privilege levels
Comma Description Example User
nd Privilege
Privilege Level
Level
For details about command privilege levels, see S300, S500, S2700, S5700, and
S6700 V200R020C10 Command Reference.
The default command privilege level setting is appropriate for user operation
rights control; therefore, you are advised not to change command privilege levels.
If there are special requirements on user operation rights of a specific-level user,
you can change the command privilege level of specified commands. For example,
if only level-4 and a higher level users are allowed to execute the stelnet
command, you can upgrade the command privilege level of the stelnet command
to level-4.
NOTE
Do not change the default privilege level of a command. Otherwise, some users may be
unable to use the command. If command privilege levels are changed separately before you
upgrade command privilege levels in a batch, the levels of these commands remain
unchanged. Therefore, you are advised to upgrade command privilege levels in a batch
before you upgrade the level of each command separately.
The execution of some commands depends on some conditions. For example, a command
can be configured only when other commands are configured or the command is an
upgrade-compatible command. When levels of these commands are adjusted using the
command-privilege level command, the adjusted commands may not be executed. Level
adjustment of a command is irrelevant to execution of the command.
Procedure
Step 1 Run system-view
----End
NOTE
Display the later Down arrow key ↓ or Ctrl+N A later history command
history command. is displayed. If the
current command is the
latest command, no
output is displayed and
an alarm is generated
when you attempt to
display the later history
command.
NOTE
You cannot access history commands using the Up arrow key ↑ in HyperTerminal Windows
9X. The Up arrow key ↑ has a different function in HyperTerminal Windows 9X and needs to
be replaced by the shortcut key Ctrl+P.
configuration command and the dis curr command are used, both of them
are saved.
● History commands entered by the current user can be deleted using the reset
history-command command in all views. The deleted history commands
cannot be displayed or accessed. To delete history commands entered by all
users, run the reset history-command [ all-users ] command as a user of
level 3 or higher.