01-01 Overview of CLIs
01-01 Overview of CLIs
1 Overview of CLIs
Licensing Requirements
CLI overview function is a basic feature of a router and is not under license
control.
Feature Limitations
None
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.
NOTE
● Some commands can be executed in multiple views, but they have different functions
after 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.
[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.
# Press Ctrl+Z to return directly to the user view.
[Huawei-aaa] // Enter Ctrl+Z
<Huawei>
Context
● The system grants users different access permissions based on their roles.
User levels are classified into sixteen levels, which correspond to the
command levels. Users can use only the commands at the same or lower level
than their own levels. By default, there are four command levels 0 to 3 and
sixteen user levels 0 to 15. Table 1-1 describes the relationship between
command levels and user levels.
NOTICE
Changing the default command level without the guidance of technical personnel
is not recommended. This may result in inconvenience for operation and
maintenance and bring about security problems.
Procedure
Step 1 Run system-view
You can perform this step to check the view of the command whose level needs to
be changed.
----End
Editing Feature
You can edit commands in a CLI that supports multi-line edition. Each command
can contain a maximum of 510 characters. The keywords in the commands are
case insensitive. Whether a command parameter is case sensitive or not depends
on what the parameter is.
Table 1-2 lists keys that are frequently used for command editing.
Key Function
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.
For example, to execute the display current-configuration command, you can
enter d cu, di cu, or dis cu, but you cannot enter d c or dis c because they do not
match unique keywords.
NOTICE
Tab
Enter an incomplete keyword and press Tab to complete the keyword.
● When a unique keyword matches the input, the system replaces the
incomplete input with the unique keyword and displays it in a new line with
the cursor leaving a space behind. For example:
a. Enter an incomplete keyword.
[Huawei] info-
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 logbuffer
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 logfile
[Huawei] info-center loghost
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, indicating 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:
arp-ping ARP-ping
autosave <Group> autosave command group
backup Backup information
cd Change current directory
clear Clear
clock Specify the system clock
cls Clear screen
compare Compare configuration file
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 <Group> debugging command group
delete Delete a file
dialer Dialer
dir List files on a filesystem
display Display information
<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 terminal and re-log in. A message "Hello, Welcome to
Huawei!" is displayed before authentication. Run the undo header login
command.
Hello,Welcome to Huawei!
Login authentication
Password:
<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:
<Huawei>
NOTE
The command output provided here is used for reference only. The actual output
information may differ from the preceding information.
By default, the system saves 10 history commands for each user. Run the history-
command max-size size-value command to reset the number of history
commands that can be saved in a specified user interface view. The maximum
number is 256.
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
The terminal in use may affect the functions of the shortcut keys. For example, if the
shortcut keys defined by the terminal conflict with those defined in the system, the shortcut
keys entered by the user are captured by the terminal program and the commands
corresponding to the shortcut keys are not executed.
The system supports four user-defined shortcut keys and the default values are as
follows:
● Ctrl+G: display current-configuration
● Ctrl+L: undo idle-timeout
● Ctrl+O: undo debugging all
● Ctrl+U: Null
NOTE
● When defining shortcut keys, use double quotation marks to define the command if this
command contains several keywords separated by spaces. For example, hotkey ctrl_l
"display tcp status". Do not use double quotation marks to define a command if the
command contains only one keyword.
● Run the display hotkey command to view the status of the defined, undefined, and
system-defined shortcut keys.
● Run the undo hotkey command to restore default values of the configured shortcut
keys.
● Shortcut keys are executed in the same way as commands. The system can record
commands in their original formats in the command buffer and logs to help query and
locate the fault.
● The user-defined shortcut keys are available to all users. If a user does not have the
rights to use the command defined by a shortcut key, the system displays an error
message when this shortcut key is executed.
Key Function
Key Function
Procedure
● Configure assistant tasks to automatically run commands in a batch at
scheduled time.
You can configure one or more scheduled tasks to realize automatic O&M.
The device can then run one or a group of commands at specified time or
after a certain delay. Assistant tasks enable the device to complete specified
operations or configuration without human intervention. Assistant tasks are
usually used for scheduled upgrading or configuration.
By default, the commands listed in the batch file are executed in the system view.
e. Run the display assistant task history [ task-name ] command to view
the operation records of task assistants.
----End
For example, after all configurations of the FTP service are complete, you can run
the display ftp-server command to check parameters of the FTP server. For
details on the usage and functions of the display command, see Checking the
Configuration in each feature of the Configuration Guide.
You can also verify the current running configurations and configurations in the
current view.
● Verify the current running configurations:
display current-configuration
This command does not display parameters that use default settings.
● Verify configurations in the current view:
display this
This command does not display parameters that use default settings.
NOTE
When a user runs the display this command to check configuration information, other
users can run this same command only after all the command output is displayed.
Context
After the administrator runs the command-privilege level command to degrade
the level of display current-configuration, low-level users can run the display
current-configuration command to view all device configurations.
To allow the low-level users to view the specified configurations, the administrator
can run the set current-configuration display command to specify the
configurations to be displayed.
Procedure
Step 1 Run the system-view command to enter the system view.
Step 2 Run the command-privilege level level view view-name command-key command
to specify the level of the display current-configuration command.
Step 3 Run the set current-configuration display [ all ] level level command-key
command to specify the configuration that a user of a specified level can view.
----End
Regular Expressions
A regular expression is a mode matching tool. It consists of common characters
(such as letters) and special characters (called meta-characters). The regular
expression is a template according to which you can search for the required string.
A regular expression provides the following functions:
● Searches for and obtains a sub-string that matches a rule in the string.
● Substitutes a string based on a certain matching rule.
The regular expression consists of common characters and special characters.
● Common characters
Common characters are used to match themselves in a string, including all
upper-case and lower-case letters, digits, punctuations, and special symbols.
For example, a matches the letter "a" in "abc", 10 matches the digit "10" in
"10.113.25.155", and @ matches the symbol "@" in "[email protected]".
● Special characters
Special characters are used together with common characters to match the
complex or special string combination. Table 1-7 describes special characters
and their syntax.
NOTE
Unless otherwise specified, all the characters in the preceding table must be printable
characters.
● 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.
● Combination of common and special characters
In actual usage, regular expressions combine multiple common and special
characters to match certain strings.
● The device 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.
● When filtering conditions are set to query output information, the first line of the
command output starts with the entire regular expression but not the string to be
filtered.
The system allows you to use | count to display the number of lines and | section
to display the command output by section after using filtering mode. | count and |
section can work together with the following filtering modes.
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.
NOTE
Example 1: Run the display interface brief command to display all the lines that
do not match the regular expression Ethernet|NULL|Tunnel. Ethernet|NULL|Tunnel
matches Ethernet, NULL or Tunnel.
<Huawei> display interface brief | exclude Ethernet|NULL|Tunnel
PHY: Physical
*down: administratively down
(l): loopback
(s): spoofing
(b): BFD down
^down: standby
(e): ETHOAM down
(d): Dampening Suppressed
InUti/OutUti: input utility/output utility
Interface PHY Protocol InUti OutUti inErrors outErrors
LoopBack1 up up(s) 0% 0% 0 0
Vlanif7 up up -- -- 0 0
Vlanif10 up up -- -- 0 0
Vlanif19 up up -- -- 0 0
Vlanif60 up up -- -- 0 0
Vlanif66 down down -- -- 0 0
Vlanif70 down down -- -- 0 0
Vlanif77 up up -- -- 0 0
Vlanif100 down down -- -- 0 0
NOTE
NOTICE
It is recommended that you do not change the default command level without the
guidance of professionals. Otherwise, it may result in inconvenience for operation
and maintenance and bring about security problems.
<Huawei> system-view
[Huawei] command-privilege level 5 view user save