0% found this document useful (0 votes)
20 views

01-01 Overview of CLIs

Uploaded by

Andrei Stelmach
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

01-01 Overview of CLIs

Uploaded by

Andrei Stelmach
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Huawei AR Series Access Routers

CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

1 Overview of CLIs

About This Chapter

This chapter describes how to perform configuration and routine maintenance on


devices by running commands.

1.1 Licensing Requirements and Limitations for CLIs


This section provides the Licensing Requirements and Limitations for CLIs.
1.2 How to Use Command Lines
This section describes how to use command lines and some techniques to improve
operating efficiency.
1.3 Displaying the Command Output
This section describes how to query the configuration information about
command lines, control the method in which command outputs are displayed, and
filter the command outputs.
1.4 FAQ of CLIs

1.1 Licensing Requirements and Limitations for CLIs


This section provides the Licensing Requirements and Limitations for CLIs.

Involved Network Elements


None

Licensing Requirements
CLI overview function is a basic feature of a router and is not under license
control.

Feature Limitations
None

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 1


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

1.2 How to Use Command Lines


This section describes how to use command lines and some techniques to improve
operating efficiency.

1.2.1 Entering Command Views


The device has many functions; therefore various configuration commands and
query commands are provided to facilitate device management and maintenance.
Huawei router registers commands to different command views based on the
functions of the commands so that users can easily use them. To configure a
function, enter the corresponding command view and then run corresponding
commands.
The device provides various command views. For the methods of entering the
command views except the following views, see the Huawei AR Series Access
Routers Command Reference.

Common Command Views


Name How To Enter Function

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>

System view Run the system-view In the system view, you


command and press can set the system
Enter in the user view. parameters of the device,
The system view is and enter other function
displayed. views from this view.
<Huawei> system-view
Enter system view, return user
view with Ctrl+Z.
[Huawei]

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 2


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Name How To Enter Function

Interface view Run the interface In the interface view, you


command and specify an can configure interface
interface type and parameters including
number to enter the physical attributes, link
interface view. layer protocols, and IP
[Huawei] interface addresses.
gigabitethernet X/Y/Z
[Huawei-GigabitEthernetX/Y/Z]

X/Y/Z indicates the


number of an interface
that needs to be
specified. It is in the
format of slot number/
card number/interface
sequence number.
The interface
GigabitEthernet is used
as an example.

Routing protocol view Run a command to In routing protocol


activate a routing views, you can configure
protocol process in the most routing protocol
system view. The parameters. The routing
corresponding routing protocol views include
protocol view is the IS-IS view, OSPF
displayed. view, and RIP view.
[Huawei] isis
[Huawei-isis-1]

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.

Exiting Command Views


You can run the quit command to return from the current view to an upper-level
view.
For example, after you run the quit command to return from the AAA view to the
system view, you can run the quit command again to return from the system view
to the user view.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 3


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

[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>

# Run the return command to return directly to the user view.


[Huawei-aaa] return
<Huawei>

1.2.2 Setting Command Levels


The system divides commands into four levels and sets the command level in the
specified view. The device administrator can change the command level as
required, so that a lower-level user can use some high-level commands. The device
administrator can also change the command level to a larger value to improve
device security.

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.

Table 1-1 Relationship between command levels and user levels


User Com Name Description
Leve man
l d
Leve
l

0 0 Visit level Commands of this level include network


diagnosis tool commands (such as ping and
tracert), commands for accessing external
devices from the local device (such as Telnet)
and some display commands.

1 0, 1 Monitorin Commands of this level are used for system


g level maintenance, including display commands.
NOTE
Some display commands are not at this level. For
example, the display current-configuration and
display saved-configuration commands are at level
3. For details about command levels, see the Huawei
AR Series Access Routers Command Reference.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 4


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

User Com Name Description


Leve man
l d
Leve
l

2 0, 1, Configura Commands of this level are used for service


2 tion level configuration to provide direct network services,
including routing commands and commands of
each network layer.

3 to 0, 1, Managem Commands of this level are used for basic


15 2, 3 ent level system operations, including file system, FTP,
TFTP download, user management, command
level configuration, and debugging.

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

The system view is displayed.

Step 2 (Optional) Run display command-view command-key

The view of a specified command is displayed.

You can perform this step to check the view of the command whose level needs to
be changed.

Step 3 Run command-privilege level level view view-name command-key

The command level is set in the specified view.

----End

1.2.3 Editing Command Lines

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 5


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Table 1-2 Keys for command editing

Key Function

Common key Inserts a character at the current location of the cursor


if the editing buffer is not full, and the cursor moves to
the right. Otherwise, an alarm is generated.

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

The maximum length of a command (including the incomplete command) to be


entered is 510 characters. If a command in incomplete form is configured, the
system saves the command to the configuration file in its complete form, which
may cause the command to have more than 510 characters. In this case, the
command in incomplete form cannot be restored after the system restarts.
Therefore, when you configure a command in incomplete form, pay attention to
the length of the command.

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 6


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

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

Stop pressing Tab when the desired keyword is displayed.


● When an incorrect keyword is entered, press Tab and it is displayed in a new
line without being changed. For example:
a. Enter an incorrect keyword.
[Huawei] info-center loglog

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.

1.2.4 Using Command Line Online Help


When using a command line, you can use the online help to obtain real-time help
without memorizing a large number of complex commands.
When entering command lines, you can enter a question mark (?) at any time to
obtain online help. You can choose to obtain full help or partial help.

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

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 7


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

copy Copy from one file to another


...

● Enter some keywords of a command and a question mark (?) separated by a


space. All keywords associated with this command, as well as simple
descriptions, are displayed. For example:
<Huawei> system-view
[Huawei] user-interface vty 0 4
[Huawei-ui-vty0-4] authentication-mode ?
aaa AAA authentication
password Authentication through the password of a user terminal interface
[Huawei-ui-vty0-4] authentication-mode aaa ?
<cr> Please press ENTER to execute command
[Huawei-ui-vty0-4] authentication-mode aaa

– "aaa" and "password" are keywords. "AAA authentication" and


"Authentication through the password of a user terminal interface"
describe the keywords respectively.
– <cr> indicates that there is no keyword or parameter in this position. You
can press Enter to run this command.
● Enter some keywords of a command and a question mark (?) separated by a
space. All parameters associated with this keyword, as well as simple
descriptions, are listed. For example:
<Huawei> system-view
[Huawei] ftp timeout ?
INTEGER<1-35791> The value of FTP timeout (in minutes)
[Huawei] ftp timeout 35 ?
<cr> Please press ENTER to execute command
[Huawei] ftp timeout 35

"INTEGER<1-35791>" describes the value range of the parameter. "The value


of FTP timeout (in minutes)" briefly describes the function of this parameter.

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 a command and a string followed directly by a question mark (?) to


display all the keywords that begin with this string. For example:
<Huawei> display b?
bfd Specify BFD(Bidirectional Forwarding Detection)
configuration information
bgp BGP information
binding Display binding relation of profile
bridge <Group> bridge command group

● 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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 8


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

NOTE

The command output obtained through the online help function is used for reference only.

1.2.5 Interpreting Command Line Error Messages


If a command is entered and passes syntax check, the system executes it.
Otherwise, the system reports an error message.
Table 1-3 lists the common error messages.

Table 1-3 Common error messages of the command line


Error Message Cause of the Error

Error: Unrecognized command No command is found.


found at '^' position.
No keyword is found.

Error: Wrong parameter found at The parameter type is incorrect.


'^' position.
The parameter value exceeds the limit.

Error: Incomplete command The entered command is incomplete.


found at '^' position.

Error: Too many parameters Too many parameters are entered.


found at '^' position.

Error: Ambiguous command Indefinite command is entered.


found at '^' position.

1.2.6 Using the undo Command Line


If a command line begins with the keyword undo, it is an undo command line.
The undo command lines restore default settings of parameters, disable functions,
or delete configurations. Almost each configuration command line has a
corresponding undo command.
Some examples of using the undo command are listed as follows:
● The undo command restores the default setting.
The sysname command sets a device host name. For example:
<Huawei> system-view
[Huawei] sysname Server
[Server] undo sysname
[Huawei]

● The undo command disables a specified function.


The ftp server enable command enables the FTP server function on the
device. For example:
<Huawei> system-view
[Huawei] ftp server enable
Info: Succeeded in starting the FTP server
[Huawei] undo ftp server
Info: Succeeded in closing the FTP server.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 9


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

● The undo command deletes a specified configuration.


The header command configures the header information displayed on
terminals when users log in. For example:
<Huawei> system-view
[Huawei] header login information "Hello,Welcome to Huawei!"

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.

1.2.7 Displaying History Commands


The device automatically stores history commands entered by a user. To enter a
command that has been executed, you can use this function to call up the history
command.

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

If the value specified in the history-command max-size size-value command is large, it


may take a long time to obtain a required history command. Therefore, a large value is not
recommended.

Table 1-4 shows operations on history commands.

Table 1-4 Accessing history commands

Action Command or Key Result

Display history display history-command The history commands


commands. entered by the current
user are displayed.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 10


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Action Command or Key Result

Display the earlier Up arrow key ↑ or Ctrl+P An earlier history


history command. command is displayed. If
the current command is
the first command, an
alarm is generated when
you attempt to display
the earlier history
command.

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.

When using history commands, note the following:


● The saved history commands are the same as those entered by users. For
example, if the user enters an incomplete command, the saved command also
is incomplete.
● If the user runs the same command several times, only the latest command is
saved. If the command is entered in different forms, they are considered as
different commands.
For example, if the display current-configuration command is run several
times, only one history command is saved. If the display current-
configuration command and the dis curr command are used, both of them
are saved.

1.2.8 Using Command Line Shortcut Keys


You can use shortcut keys provided by the device to quickly enter commands.
There are two types of shortcut keys:
● User-defined shortcut keys: include Ctrl+G, Ctrl+L, Ctrl+O, and Ctrl+U. You can
associate these shortcut keys with any commands. When a shortcut key is
pressed, the system runs the corresponding command.
● System-defined shortcut keys: shortcut keys defined in the system that have
fixed functions. Users cannot define these shortcut keys. Table 1-5 lists the
frequently used system-defined shortcut keys.

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 11


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

User-defined Shortcut Keys


When a user frequently uses a command or some commands, the user can use
shortcut keys to define these commands. Only management-level users have the
rights to define shortcut keys. The configurations are as follows:
1. Run the system-view command to enter the system view.
2. Run the hotkey { CTRL_G | CTRL_L | CTRL_O | CTRL_U } command-text
command to configure a shortcut key corresponding to a command.

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.

System-defined Shortcut Keys

Table 1-5 System-defined shortcut keys

Key Function

Ctrl+A Moves the cursor to the beginning of the


current line.

Ctrl+B Moves the cursor back one character.

Ctrl+C Stops performing current functions.

Ctrl+D Deletes the character where the cursor is


located at.

Ctrl+E Moves the cursor to the end of the last


line.

Ctrl+F Moves the cursor forward one character.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 12


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Key Function

Ctrl+H Deletes the character on the left side of


the cursor.

Ctrl+K Stops outgoing connections in the call


establishment stage.

Ctrl+N Displays the next command in the history


command buffer.

Ctrl+P Displays the previous command in the


history command buffer.

Ctrl+T Function as a question mark.

Ctrl+W Deletes a character string on the left side


of the cursor.

Ctrl+X Deletes all the characters on the left side


of the cursor.

Ctrl+Y Deletes all the characters on the right


side of the cursor and the character
where the cursor is located at.

Ctrl+Z Returns to the user view.

Ctrl+] Stops incoming connections or redirects


the connections.

Esc+B Moves the cursor back one word.

Esc+D Deletes one word on the right side of the


cursor.

Esc+F Moves the cursor forward one word.

1.2.9 Executing Commands in a Batch


If multiple commands are frequently used consecutively, you can edit these
commands to be executed in batches. This simplifies command input and
improves efficiency.

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 13


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

a. Run the system-view command to enter system view.


b. Run the assistant task task-name command to create an assistant task.
You can create a maximum of five assistant tasks.
c. Run the if-match timer cron seconds minutes hours days-of-month
months days-of-week [ years ] command to specify the time when the
assistant tasks work.
d. Run the perform priority batch-file filename command to configure the
operations of assistant tasks.
NOTE

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.

This function promotes the automatic control and management abilities of


the device, reducing power consumption.

----End

1.3 Displaying the Command Output


This section describes how to query the configuration information about
command lines, control the method in which command outputs are displayed, and
filter the command outputs.

1.3.1 Verifying Command Line Configurations


After the configurations are complete, you can run the display command to verify
the configuration and running information on the device.

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 14


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

1.3.2 Configuring Users of Different Levels to View Different


Configurations
The device allows users of different levels to view specified configurations, so
users can view outputs of specified command lines.

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

Verifying the Configuration


Log in to the device as a user of the specified level and run the display current-
configuration command.

1.3.3 Controlling the Display Mode of Commands


When running commands, you can specify the display mode.
● When the display output is more than one page, you can use Pg Up and Pg
Dn to display information on the previous page and the next page.
● When the information cannot be completely displayed on one screen, the
system will pause and you can view the information. You can use the function
keys listed in Table 1-6 to control the display mode of command lines.
NOTE
The screen-length screen-length temporary command sets the lines to be displayed
temporarily on the terminal screen. If screen-length is 0, the split screen function is
disabled. Therefore, the system will not pause when the information cannot be
completely displayed on one screen.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 15


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Table 1-6 Display mode of commands


Key Function

Ctrl+C or Ctrl+Z Stops displaying information and running


commands.
NOTE
You can also press any key (the number key or
letter key) except space and Enter.

Space Continues to display the next screen of


information.

Enter Continues to display the next line of


information.

1.3.4 Filtering Command Outputs


When running the display command to check the command output, you can use
the regular expression (specifying the rule to display) to filter the output
information and locate needed information quickly.

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 16


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Table 1-7 Description of special characters


Special Function Example
Charact
ers

\ Defines an escape character, \* matches "*".


which is used to mark the next
character (common or special)
as the common character.

^ Matches the starting position ^10 matches "10.10.10.1"


of the string. instead of "20.10.10.1".

$ Matches the ending position of 1$ matches "10.10.10.1"


the string. instead of "10.10.10.2".

* Matches the preceding 10* matches "1", "10", "100",


element zero or more times. "1000", and so on.
(10)* matches "null", "10",
"1010", "101010", and so on.

+ Matches the preceding 10+ matches "10", "100",


element one or more times. "1000", and so on.
(10)+ matches "10", "1010",
"101010", and so on.

? Matches the preceding 10? matches "1" or "10".


element zero or one time. (10)? matches "null" or "10".

. Matches any single character. 0.0 matches "0x0", "020", and


so on.
.oo. matches "book", "look",
"tool", and so on.

() Defines a subexpression, which 100(200)+ matches "100200",


can be null. Both the "100200200", and so on.
expression and the
subexpression should be
matched.

x|y Matches x or y. 100|200 matches "100" or


"200".
1(2|3)4 matches "124" or
"134", instead of "1234", "14",
"1224", and "1334".

[xyz] Matches any single character [123] matches the character 2


in the regular expression. in "255".

[^xyz] Matches any character that is [^123] matches any character


not in the regular expression. except for "1", "2", and "3".

[a-z] Matches any character within [0-9] matches any character


the specified range. ranging from 0 to 9.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 17


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Special Function Example


Charact
ers

[^a-z] Matches any character beyond [^0-9] matches all non-


the specified range. numeric characters.

_ Matches a comma ",", left _2008_ matches "2008", "space


brace "{", right brace "}", left 2008 space", "space 2008",
parenthesis "(", and right "2008 space", ",2008,",
parenthesis ")". "{2008}", "(2008)", "{2008)",
Matches the starting position and "(2008}".
of the input string.
Matches the ending position of
the input string.
Matches a space.

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.

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 18


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

Specifying a Filtering Mode in a Command


NOTE

● 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

The value of regular-expression is a string of 1 to 255 characters. regular-expression cannot


contain underlines ([).

The following examples describe how to specify a filter mode in a command.

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

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 19


Huawei AR Series Access Routers
CLI-based Configuration Guide - Basic Configuration 1 Overview of CLIs

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

Example 2: Run the display current-configuration command to display all the


lines that match the regular expression vlan.
<Huawei> display current-configuration | include vlan
vlan batch 7 10 18 to 19 30 60 66 70 77 100 105
vlan batch 200 1024
port default vlan 77
port default vlan 19
port hybrid pvid vlan 10
port hybrid untagged vlan 10
port hybrid pvid vlan 60
undo port hybrid vlan 1
port hybrid tagged vlan 60
port trunk allow-pass vlan 60
port hybrid pvid vlan 10
port hybrid tagged vlan 7
port hybrid untagged vlan 10

NOTE

The preceding information is used for reference only.

1.4 FAQ of CLIs

1.4.1 What Are Shortcut Keys ESC_B and ESC_F For?


ESC_B moves the cursor forward one word, whereas ESC_F moves the cursor back
one word.

1.4.2 How Do I Define the Command Level?


The administrator can run the command-privilege level level view view-name
command-key command to set the command level in a specified view. This
configuration enables a lower-level user to use some high-level commands, or
raises the command level to improve device security.

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

Issue 13 (2023-08-01) Copyright © Huawei Technologies Co., Ltd. 20

You might also like