NetEngine 8000 M14K, M14, M8K, M8, M4, 8000E M14 M8, 8100 M14 M8 V800R022C00SPC600 Configuration Guide
CLI Overview Configuration
- How to Use the CLI
- Entering Command Views
- Selecting a Mode for the Configuration to Take Effect
- Disabling the Re-confirmation Function
- Intelligent Command Backtracking
- Setting Command Privilege Levels
- Editing Command Lines
- Using Command Online Help
- Interpreting Command Error Messages
- Using an undo Command
- Displaying Historical Commands
- Using Command Line Shortcut Keys
- Configuring an Alias for a Command
- Replacing Characters
- Running User View Commands in the System View
- Configuring the Command Timestamp
- Enabling Secondary Authentication
- Displaying the Command Output
- Configuring the Session Logging Function
How to Use the CLI
Entering Command Views
Devices provide rich functions and a variety of configuration and query commands for device configuration, management, and maintenance. To simplify the use of such commands on the Huawei devices, these commands are registered in different command views based on their functions. To configure a function, you need to enter the required command view and run the required commands.
A device provides various command views. The following describes the most commonly used command views. For instructions on how to enter command views not listed below, see the Command Reference.
Common Command Views
User view
The user view allows you to check statistics and view the operating status of the device.
You automatically enter the user view after logging in to the device, and the following prompt is displayed:
<HUAWEI>
System view
The system view allows you to set the device's system parameters and enter other function views.
To enter the system view, run the system-view command and press Enter while in the user view.
<HUAWEI> system-view Enter system view, return user view with return command. [~HUAWEI]
Interface view
You can configure interface parameters in the interface view. Interface parameters include physical attributes, link layer protocols, and IP addresses.
To enter the interface view, run the interface command and specify an interface type and number. A GE interface is used here as an example.
[~HUAWEI] interface gigabitethernet X/Y/Z [~HUAWEI-GigabitEthernetX/Y/Z]
X/Y/Z indicates the interface number that needs to be specified, and is displayed in the following format: slot number/subcard number/interface sequence number.
Routing protocol view
Routing protocol views enable you to configure most routing protocol parameters. The routing protocol views include the IS-IS view, the OSPF view, and the RIP view.
To enter a routing protocol view, run a specific command to activate a routing protocol process in the system view.
[~HUAWEI] isis [~HUAWEI-isis-1]
The command line prompt HUAWEI is the default host name (sysname), and the prompt indicates the current view. For example, <> indicates the user view and [] indicates all other views.
To add comments, 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.
Some commands can be executed in multiple views, while their functions depend on the views these commands are executed.
- In the system view, you can run the diagnose command to enter the diagnostic view. Diagnostic commands are used for device fault diagnosis, and running certain commands in this view may cause the device unable to work properly or interrupt services. To use these diagnostic commands, contact technical support.
Exiting Command Views
To return from the current view to an upper-level view, run the quit command.
[~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.
[~HUAWEI-aaa] //Enter Ctrl+Z. <HUAWEI>
[~HUAWEI-aaa] return <HUAWEI>
Selecting a Mode for the Configuration to Take Effect
To ensure the reliability of user configurations, the system allows configurations to take effect immediately or after two stages. The two-stage mode is used by default.
Before configuring a service, enter the system view. After the system view is displayed, the system initiates the corresponding configuration process based on the configured mode.
The immediate mode is the traditional mode.
In immediate mode, after you enter a command line and press Enter, the system performs a syntax check. The configuration takes effect as soon as it passes the syntax check.
The two-stage mode divides the system configuration process into two stages.
In the first stage, a user enters command lines and the system performs syntax and semantics checks in the candidate database. If syntax or semantics errors are found in the command lines, the system displays a message on the terminal to inform the user of the error and the cause.
In the second stage, the user commits the configuration, and the system enters the configuration commitment stage. The system delivers configurations in the candidate database to a service. If these service configurations take effect, the system adds them to the running database of the current system. During the configuration commitment stage, the system checks the validity of configurations and displays a message when the same configurations exist in the candidate database and running database.
Mode |
Advantage |
Disadvantage |
---|---|---|
Immediate mode |
The system can immediately detect configuration impacts on services. |
Any configuration errors will immediately impact services. In addition, you cannot delete service configurations all at once, and must delete commands individually. |
Two-stage mode |
|
Configurations take effect only after the commit command is run. |
- Query commands (such as display interface) are run.
- Maintenance commands (such as reset saved-configuration and reset keepalive packets count) are run.
- Commands such as interface GigabitEthernet0/1/1 are run to enter the existing views (such as the physical interface view) on a physical device.
- Commands are run without changing the existing configurations.
Immediate Mode
system-view immediately
In immediate mode, the command line prompt is as follows:
<HUAWEI> system-view immediately Enter system view, return user view with return command. [HUAWEI]
Two-Stage Mode
- Enable the two-stage mode.
system-view
- (Optional) Display all uncommitted configurations.
display configuration candidate [ merge | changes ]
If you do not specify the merge and changes keywords, the command displays uncommitted configurations only. If you specify the merge keyword, the command displays both uncommitted and committed configurations. The changes keyword is specified to display the differences between the uncommitted configurations and current running configurations.
You can edit uncommitted configurations.
If the system displays a message indicating that the current running configurations are changed when you run the display configuration candidate changes command, run the refresh configuration candidate command to resolve the configuration conflict so that you can continue to view the configuration differences.
- (Optional) Delete all uncommitted configurations.
clear configuration candidate
- (Optional) Enable a trial run of system configurations.
commit trial [ time ] [ persist persistId ]
This command enables a trial run of new functions and services without interrupting those running on the live network, which improves network reliability. When the trial running period elapses, the configurations in trial running state are automatically rolled back. If the persist parameter is not specified, the configuration trial run takes effect only in the current session. If the persist parameter is specified, the configuration trial run does not stop when the session ends.
To disable the trial run of configurations before the trial run times out, run the abort trial command to roll the system configurations back to those used before the trial run. To view the trial run status of system configurations, run the display configuration trial status command.
- Commit configurations.
commit [ persist persistId ]
Before the persistent trial run is rolled back due to timeout, you can specify the persist keyword in any session to commit the configurations in trial run.
In two-stage mode, if the user modifies but not commits configurations, the system prompt ~ is changed to *, notifying the user that the configurations are not committed. After the user runs the commit command to commit the configurations, the system prompt * is restored to ~.
For example:
<HUAWEI> system-view Enter system view, return user view with return command. [~HUAWEI] sysname HUAWEIA [*HUAWEI] commit [~HUAWEI]
In both the immediate and two-stage modes, the system can lock the configuration of a service as soon as the service process starts, in order to prevent a service from being affected. In this situation, users can query configurations but cannot edit or commit them. If configurations fail to be committed, you are advised to wait for 30 seconds before retrying. If configurations still fail to be committed, the configurations are locked by a user.
You can run the configuration exclusive command to lock a configuration. If a configuration is locked by another user, you will need to ask the user to unlock it.
- In two-stage mode, when multiple users perform the same configuration, only the first committed configuration takes effect. Other users will receive a configuration conflict prompt.
Disabling the Re-confirmation Function
Misoperations of some undo commands will delete the configurations of related features. As a result, services are interrupted and the user network is disconnected. By default, re-confirmation is required before the following commands are run: undo mpls, undo mpls te, undo mpls rsvp, undo mpls ldp, undo mpls l2vpn, undo multicast ipv6 routing-enable, undo multicast routing-enable, undo pim, undo igmp, undo bfd, and undo stp enable.
To disable the re-confirmation function, run the configuration prevent-misoperation disable command in the system view.
To prevent some services from being unavailable due to misoperations, you are advised to enable the re-confirmation function.
Intelligent Command Backtracking
Each command can be run in some specific views. For example, the vlan command can be run in the system view. During service deployment, you may need to run commands in different views, which complicates operations and reduces service deployment efficiency.
Commands that can be run in the system view support the intelligent backtracking function. If a command cannot be run in the current view (a non-system and non-user view), the system automatically returns to the system view. If the command can be run in the system view, the corresponding configuration is directly delivered, enhancing ease of use of the command.
<HUAWEI> system-view [~HUAWEI] vlan 2 [*HUAWEI-vlan2] interface gigabitethernet 0/1/1 [*HUAWEI-GigabitEthernet0/1/1]
To disable intelligent command backtracking, run the undo terminal command forward matched upper-view command in the user view. By default, intelligent command backtracking is enabled.
In some cases, the system automatically disables intelligent command backtracking to prevent service deployment from being affected. For example, a command can be run in the system view and the interface view, but generate different configurations in the two views. If a service that conflicts with the command is configured in the interface view, this command cannot be run in the interface or system view.
Intelligent command backtracking requires a complete command line to be entered, and the command word cannot be automatically displayed through the question mark help function.
Setting Command Privilege Levels
Context
The system manages commands based on command privilege levels. Each command to be run in a command view has its privilege level. The device administrator can change the command privilege level as required, enabling lower-level users to run some high-level commands. The device administrator can also increase the command privilege level to improve device security.
A device manages users by level, and maintains the relationship between user privilege levels and command privilege levels in order to limit user access permissions. After a user logs in to a device, the user can only use commands at the user's privilege level and below. By default, the values of both command privilege levels and user privilege levels range from 0 to 3. Table 1-3 describes the relationship between user privilege levels and command privilege levels when the command-privilege level rearrange command is not configured.
Table 1-3 Relationship between command privilege levels and user privilege levelsUser Privilege Level
Command Privilege Level
Description
0
Visit level (0)
Commands at this privilege 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
Visit level (0) and monitoring level (1)
Commands at this level are used for system maintenance, including display commands.NOTE:Not all display commands are at this level. For example, the display current-configuration and display saved-configuration configuration commands are at level 3. For details about command privilege levels, see the Command Reference.
2
Visit level (0), monitoring level (1), and configuration level (2)
Commands at this privilege level are used for service configurations to provide network services, including routing, Layer 2, and Layer 3 commands.
3
Visit level (0), monitoring level (1), configuration level (2), and management level (3)
Commands at this privilege level are used for basic system operations, including file system, FTP, TFTP download, command privilege level configuration, and debugging.
- If refined right management is required, run the command-privilege level rearrange command to increase command privilege levels.
To prevent security risks to devices, you are not advised to change the default command privilege level.
Procedure
- Enter the system view.
system-view
- Set the command privilege level in the specified view.
command-privilege level level view view-name command-key
- (Optional) Increase command privilege levels in batches.
command-privilege level rearrange
You can use this command only when your user privilege level is management level (3 or 15). The user management level can be the default level 3 or the level 15 after privilege escalation.
If the privilege level of a command has been changed using the command-privilege level command, the command-privilege level rearrange command does not take effect for this command. Privilege levels of other commands are changed as follows:
The commands of Level 0 and Level 1 remain unchanged.
The configuration level is increased to level 10, and the management level is increased to level 15.
After the privilege levels of commands are increased in batches, there are no commands at levels 2 to 9 and levels 11 to 14. You can set commands to any of these levels for refined user rights management.
- Commit the configuration.
commit
Editing Command Lines
Function Overview
You can edit command lines in a CLI. Each command can contain a maximum of 3100 characters. The keywords in the commands are case insensitive, and whether a command parameter is case sensitive depends on the parameter.
Table 1-4 lists keys that are frequently used for editing command lines
Key |
Function |
---|---|
Common key |
Inserts a character at the current location of the cursor and moves the cursor forward if the editing buffer is not full. Otherwise, an alarm is generated. |
Backspace |
Deletes the character before the cursor and moves the cursor back one character. When the cursor reaches the beginning of the command, an alarm is generated. |
Left cursor key ← or Ctrl+B |
Moves the cursor back one character. When the cursor reaches the beginning of the command, an alarm is generated. |
Right cursor key → or Ctrl+F |
Moves the cursor forward one character. When the cursor reaches the end of the command, an alarm is generated. |
How to Edit Command Lines
Incomplete Keyword
You are not required to enter complete keywords on the device, as long as entered characters can match a unique keyword. This function improves operating efficiency.
If the current input keyword matches multiple commands, you need to type more of the keyword until it can match a unique command. Then the command can be successfully delivered.
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.
The maximum length of a command (including an incomplete command) is 3100 characters. If an incomplete command is configured, the system saves this command to the configuration file in its complete format, which may cause the command to have more than 3100 characters. In this case, the incomplete commands cannot be restored after the system restarts. As such, you must pay attention to the length of a command when configuring it in incomplete format.
Tab
- When the input matches a unique keyword, the system replaces it with the unique keyword and displays it in a new line with the cursor leaving a space behind. For example:
Enter an incomplete keyword.
[~HUAWEI] info-
Press Tab.
The system replaces the entered keyword with the complete keyword in a new line with the cursor leaving a space behind.[~HUAWEI] info-center
- When the input has multiple matches, press Tab repeatedly to display the keywords beginning with the incomplete input one by one until the desired keyword is displayed. In this case, the cursor immediately follows the end of the keyword. For example:
Enter an incomplete keyword.
[~HUAWEI] info-center log
Press Tab.
The system displays the prefixes of all matched keywords. In this example, the prefix is log.[~HUAWEI] info-center log-severity
Press Tab to switch from one matched keyword to another. In this case, the cursor immediately follows the end of the keyword.[~HUAWEI] info-center logbuffer [~HUAWEI] info-center logfile [~HUAWEI] info-center loghost
Stop pressing Tab when the desired keyword is displayed.
- When a keyword that matches no command is entered, press Tab and the keyword is displayed in a new line without being changed. For example:
Enter an incorrect keyword.
[~HUAWEI] info-center loglog
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 keyword, indicating that this keyword does not exist.
Using Command Online Help
You can use command online help to obtain real-time assistance, avoiding the need to memorize a large number of complex commands.
When entering commands, you can enter a question mark (?) at any time to obtain online help. You can choose to obtain either full or partial help.
Full Help
When entering a command, you can use the full help function to obtain all the keywords and parameters of the command. Use any of the following methods to obtain full help for commands.
- Enter a question mark (?) in any command view to obtain all the commands and their simple descriptions in this command view. For example:
<HUAWEI> ? Current view commands: activate Activate locked user cd Change current directory clear Clear operation clock Clock status and configuration information copy Copy from one file to another ...
- Enter some keywords of a command and a question mark (?) separated by a space to display all the keywords associated with this command, as well as simple descriptions. 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
In the preceding command output, the description of the aaa keyword is AAA authentication, and the description of the password is Authentication through the password of a user terminal interface.
- Enter some keywords of a command and a question mark (?) separated by a space to display all the parameters associated with this keyword, as well as simple descriptions. For example:
<HUAWEI> system-view [~HUAWEI] ssh server timeout ? INTEGER<1-35791> Set the authentication timeout, the default value is 60 seconds [~HUAWEI] ssh server timeout 35 ? <cr> [~HUAWEI] ssh server timeout 35
INTEGER<1-35791> describes the value range of the parameter. Set the authentication timeout, the default value is 60 briefly describes the function of this parameter. <cr> indicates that there is no keyword or parameter in this position. You can press Enter to run this command.
Partial Help
If you enter one or more of the first few characters of a command keyword, partial help provides all the keywords that begin with this character or character string. Use any of the following methods to obtain partial help for commands.
- 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 a command and a string followed directly by a question mark (?) to display all the keywords that begin with this character string. For example:
<HUAWEI> display b? bfd bgp
- Enter the first several letters of a keyword in a command and press Tab to display a complete keyword. However, the first several letters must uniquely identify the keyword. Otherwise, keep pressing Tab to display different keywords and select the required one.
The command output obtained through the online help function is used for reference only.
Interpreting Command Error Messages
If a command passes the syntax check, it will be executed by the system. Otherwise, the system reports an error message.
Table 1-5 lists common error messages.
Error Message |
Error Cause |
---|---|
Error: Unrecognized command found at '^' position. |
No command is found. |
No keyword is found. |
|
Error: Wrong parameter found at '^' position. |
The parameter type is incorrect. |
The parameter value exceeds the limit. |
|
Error: Incomplete command found at '^' position. |
The entered command is incomplete. |
Error: Too many parameters found at '^' position. |
Too many parameters are entered. |
Error: Ambiguous command found at '^' position. |
Unspecific command is entered. |
Using an undo Command
An undo command restores a default configuration, disables a function, or deletes a configuration. Most configuration commands have a corresponding undo command.
Some examples of using undo commands are as follows:
- Run an undo command to restore a default configuration.
For example, the undo sysname command restores the default device host name. For example:
<HUAWEI> system-view [~HUAWEI] sysname Server [*HUAWEI] commit [~Server] undo sysname [*Server] commit [*HUAWEI]
- Run an undo command to disable a function.
The undo sftp server enable command disables the SFTP server function on the device. For example:
<HUAWEI> system-view [~HUAWEI] sftp server enable Info: Succeeded in starting the SFTP server. [*HUAWEI] commit [~HUAWEI] undo sftp server Warning: The operation will stop the SFTP server. Continue? [Y/N]:Y Info: Succeeded in closing the SFTP server. [*HUAWEI] commit
- Run an undo command to delete a configuration.
The undo header command deletes the header information displayed on devices when users log in. For example:
<HUAWEI> system-view [~HUAWEI] header login information "Hello,Welcome to Huawei!" [*HUAWEI] commit
Log out of the device and re-log in. A message "Hello, Welcome to Huawei!" is displayed before authentication. Run the undo header login command.
Hello,Welcome to Huawei! Password: Info: The max number of VTY users is 21, and the number of current VTY users on line is 2. The current login time is 2019-11-06 16:31:24. <HUAWEI> system-view [~HUAWEI] undo header login [*HUAWEI] commit
Log out of the device and re-log in. No message is displayed before authentication.
Password: Info: The max number of VTY users is 21, and the number of current VTY users on line is 2. The current login time is 2019-11-06 16:45:06. <HUAWEI>
The command output provided here is used for reference only, and actual output information may differ.
Displaying Historical Commands
The device automatically saves a user's historical commands. If you want to enter a command that has already been executed, you can use the function of displaying historical commands to find the desired one.
By default, the device saves the last 10 commands for each user. You can run the history-command max-size size-value command in a user interface view to set the number of historical commands that can be saved for the corresponding user. The maximum number is 256.
The time spent in finding the desired command among all the historical commands saved on the device is related to the value specified in the history-command max-size size-value command. To ensure an efficient search, set an appropriate value.
Table 1-6 describes the operations on historical commands.
Action |
Command or Key |
Result |
---|---|---|
Display historical commands. |
display history-command [ all-users ] |
|
Display the previous historical command. |
Up arrow key ↑ or Ctrl+P |
The previous historical command is displayed. If the current command is the first historical command, an alarm is generated when you attempt to display the previous historical command. |
Display the next historical command. |
Down arrow key ↓ or Ctrl+N |
The next historical command is displayed. If the current command is the latest historical command, no output is displayed and an alarm is generated when you attempt to display the next historical command. |
The HyperTerminal bundled with Windows 9X that defines a different function of the Up arrow key ↑, where you need to use the Ctrl+P shortcut key instead to access historical commands.
Note the following when displaying historical commands:
The device saves commands in the same way as how users enter them. For example, if a user enters an incomplete command, the saved command will also be incomplete.
If a user runs the same command several times, only the most recently entered command is saved. If a command is entered in different formats, the command in each of these formats is considered different.
For example, if the display current-configuration command is run several times, this command last executed is saved. If the display current-configuration command and the dis curr command are run, both of them are saved.
Historical commands entered by the current user can be deleted using the reset history-command command in the user view, and those entered by all users can be deleted using the reset history-command all-users command in the user view. Once deleted, historical commands can no longer be displayed or accessed.
Using Command Line Shortcut Keys
A device provides command shortcut keys to speed up and simplify command input.
There are four user-defined shortcut keys: Ctrl+G, Ctrl+L, Ctrl+O, and Ctrl+U. A user-defined shortcut key can be associated with any command. After you press a shortcut key, the system will automatically run the command associated with the shortcut key.
System default shortcut keys: shortcut keys defined in the system that have fixed functions and cannot be defined by users. Table 1-7 lists the common system shortcut keys.
The terminal being used may affect the functions of the shortcut keys. For example, if the shortcut keys defined by the terminal conflict with those defined in the device, the shortcut keys entered by the user are identified by the terminal program and the commands corresponding to the shortcut keys are not executed.
User-defined Shortcut Keys
If a user frequently uses a specific command or selection of commands, the user can use shortcut keys to define them. Only management-level users have the rights to define shortcut keys. The configurations are as follows:
- Enter the system view.
system-view
- Configure a shortcut key for a command.
hotkey { CTRL_G | CTRL_L | CTRL_O | CTRL_U } command-text
The system supports four user-defined shortcut keys and the default values are as follows:Ctrl+G: display current-configuration
Ctrl+L: display ip routing-table
Ctrl+O: undo debugging all
Ctrl+U: Null
- Commit the configuration.
commit
When defining shortcut keys, use double quotation marks to surround a command that contains several keywords separated by spaces, for example, hotkey ctrl_l "display tcp status". Do not use double quotation marks to surround a command that 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 the default values of the configured shortcut keys.
Entering shortcut keys is equivalent to command execution. The device records the commands corresponding to the entered shortcut keys in the command buffer and logs for fault detection and query.
The user-defined shortcut keys are available to all users. However, if a user does not have the rights to use the command defined by a shortcut key, the system displays an error message when the user uses this shortcut key.
System-defined Shortcut Keys
Key |
Function |
---|---|
<Ctrl+A> |
Moves the cursor to the beginning of the current command line. |
<Ctrl+B> |
Moves the cursor back one character. |
<Ctrl+C> |
Stops performing the current functions. |
<Ctrl+D> |
Deletes the character where the cursor is located. |
<Ctrl+E> |
Moves the cursor to the end of the current command line. |
<Ctrl+F> |
Moves the cursor forward one character. |
<Ctrl+H> |
Deletes the character before 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+R> |
Re-displays information about the current command line. |
<Ctrl+T> |
Stops outgoing connections. |
<Ctrl+V> |
Pastes the text of the clipboard. |
<Ctrl+W> |
Deletes the word before the cursor. |
<Ctrl+X> |
Deletes all characters before the cursor. |
<Ctrl+Y> |
Deletes all characters following the cursor and the character where the cursor is located. |
<Ctrl+Z> |
Returns to the user view. |
<Ctrl+]> |
Stops incoming connections or redirects them. |
<Esc+B> |
Moves the cursor back one word. |
<Esc+D> |
Deletes the word following the cursor. |
<Esc+F> |
Moves the cursor forward one word. |
<Esc+N> |
Moves the cursor downwards a line. |
<Esc+P> |
Moves the cursor upwards a line. |
<Esc+<> |
Positions the cursor at the beginning of the text to be copied. |
<Esc+>> |
Positions the cursor at the end of the text to be copied. |
Configuring an Alias for a Command
Context
The command alias function allows you to define your preferred character strings for commands to facilitate command usage.
Configure an easy-to-remember string of characters as the alias for a command or command keyword. By doing this, you only need to enter the alias when you want to run the command. For example, if you define the alias for display as show, you only need to enter the show command instead of display.
Adjust the order of parameters to cater for your need. For example, after you configure the alias showif parameter $ifnum $iftype command "display interface $iftype $ifnum" command, you can enter showif 1 Eth-Trunk to substitute display interface Eth-Trunk 1.
To enable the command alias function for the current terminal, run the terminal command alias command. To disable the command alias function for the current terminal, run the undo terminal command alias command. Disabling the command alias function does not delete the existing alias configuration. Therefore, the existing alias configuration will continue to take effect after you enable the command alias function again for the current terminal. To check whether or not the command alias function is enabled, you can run the display terminal command alias command.
Replacing Characters
Context
If a character string or a type of character strings on a device does not meet requirements, perform the following operations to replace the characters in batches. This function replaces only the character strings in the current view.
This function is supported only in the two-phase configuration validation mode.
Running User View Commands in the System View
Configuring the Command Timestamp
Context
To record the command execution time, you can configure the device to display the system timestamp or the command timestamp of the current session.
Procedure
- Configure the device to display the system timestamp.
system-view timestamp enable commit
This function takes effect only for display commands.
- Configure the device to display the command timestamp of the current session.
terminal command timestamp
- After this function is enabled, the execution date and time is displayed after you enter any command and press Enter.
- This command takes effect only for the current session. After you log out of and log in to the device, this function becomes invalid and needs to be reconfigured if needed.
- If you run the undo terminal command timestamp command to disable the command timestamp function of the current session after running the timestamp enable command to enable the system timestamp function, timestamps are still displayed after you run display commands.
Enabling Secondary Authentication
Context
Misoperations of some commands cause the configurations of related features to be deleted, interrupting services and disconnecting the user network. To prevent misoperations, you can run the configuration re-authentication enable command to enable secondary authentication.
After secondary authentication is enabled, you need to enter the login password for secondary authentication before running the reboot, undo mpls, undo mpls te, undo mpls rsvp, undo mpls ldp, undo mpls l2vpn, undo multicast ipv6 routing-enable, undo multicast routing-enable, undo pim, undo igmp, undo bfd, undo stp enable, or reset saved-configuration command.
- To prevent some services from being unavailable due to misoperations, you are advised to enable secondary authentication.
- By default, secondary authentication is disabled for the execution of risky commands.
Displaying the Command Output
Displaying Command Configurations
After completing the configurations on a device, you can run the display command to check the configuration and running information.
For example, after the SFTP server configuration is complete, you can run the display ssh server-info command to check the RSA and ECC public keys bound to the SSH server that is connected to the device functioning as an SSH client or the SSH server that was connected to the device. For details about the usage and functions of the display command, see "Verifying the Configuration" in each feature of the Configuration Guide.
Check the configurations running on the device:
display current-configuration
This command does not display the default parameter settings.
Check configurations in the current view:
display this
This command does not display the default parameter settings.
You can run the timestamp enable command to enable the timestamp function in the system to ensure that the system adds the query time to the output of the display command.
If the value of a parameter in the command output is too long, it will be truncated to fit.
Checking the Diagnostic Information
When the system experiences a fault or is during routine maintenance, you can check diagnostic information to collect the running information of all modules.
display diagnostic-information [ level level_value ] [ module-name ] &<1-8> [ slot slot-id ] [ key key-string ] [ force ] display diagnostic-information [ level level_value ] [ module-name ] &<1-8> [ slot slot-id ] [ key key-string ] [ force ] file-name display diagnostic-information [ level level_value ] [ module-name ] &<1-8> file-name [ slot slot-id ] [ key key-string ] [ force ]
The display diagnostic-information command output includes the output for multiple display commands, such as display clock, display version, and display current-configuration. Running the display diagnostic-information command is equivalent to running these display commands in batches.
Controlling Command Display
You can control how a command output will be displayed with function keys to meet your needs.
When a command output occupies more than one screen, you can use PgUp and PgDn to display information on the previous screen and the next screen.
When a command output occupies more than one screen, the system pauses after each screen, facilitating your information check. You can use the function keys listed in Table 1-8 to control the display mode of command lines.
The screen-length screen-length temporary command sets the lines to be displayed temporarily on the terminal screen. If the screen-length value is 0, the command output will be continuous. Therefore, the system will not pause when the information cannot be completely displayed on one screen.
Key |
Function |
---|---|
Ctrl+C or Ctrl+Z |
Stops displaying information or running commands.
NOTE:
You can also press any key except the Space and Enter keys. |
Space |
Continues to display the information on the next screen. |
Enter |
Continues to display the information in the next line. |
Filtering Command Outputs
Filtering command outputs help you quickly find the information you need. For example, you can use a regular expression (specifying the rule to filter information) in a display command to filter the output information.
Command Output Display
When the displayed information cannot be completely output on one screen, you can use the pause function to view the information on that screen, before moving onto the next screen. Table 1-9 describes the display functions.
Regular Expressions
A regular expression is a mode matching tool that consists of common characters (such as letters from a to z) and special characters (also called meta-characters). It functions as a template to match a character pattern with the searched character string.
Checks and obtains the sub-character string that matches a certain rule in the character string.
Replaces the character string based on the matching rule.
A regular expression consists of the following characters:
Common characters
A regular expression matches a string against the defined common characters. Common characters include all uppercase and lowercase letters, digits, punctuations, and special characters. For example, a matches the letter "a" in "abc", 10 matches the digits "10" in "10.113.25.155", and @ matches the symbol "@" in "xxx@xxx.com".
Special characters
Special characters, together with common characters, match complicated or special character strings. Table 1-10 describes special characters and their syntax.
Table 1-10 Special characters and their functionsSpecial Character
Function
Example
\
Defines an escape character. It converts a special or common character next to it into a common character.
\* matches *.
^
Matches the start of the string.
^10 matches 10.10.10.1 instead of 172.16.1.1.
$
Matches the end of the string.
1$ matches 10.10.10.1 instead of 10.10.10.2.
*
Matches a sub-regular expression that it follows for zero or multiple times.
10* matches 1, 10, 100, 1000, and so on.
(10)* matches null, 10, 1010, 101010, and so on.
+
Matches a sub-regular expression that it follows once or for multiple times.
10+ matches 10, 100, 1000, and so on.
(10)+ matches 10, 1010, 101010, and so on.
?
Matches a sub-regular expression that it follows for zero times or once.
NOTE:When regular expressions with a question mark (?) are entered on Huawei datacom devices, the command help information is displayed. However, if the command output is displayed on more than one screen and filter criteria followed by a question mark (?) are entered, this question mark is considered a special character of a regular expression.
10? matches 1 or 10.
(10)? matches null or 10.
.
Matches any single character.
a.b matches any string of three characters that starts with a and ends with b.
0.0 matches 0x0, 020, and so on.
.oo matches book, look, tool, and so on.
()
Matches and captures a sub-regular expression within the parentheses.
If there is no value within the parentheses, the string is equivalent to a null string.
If a pattern string has only (), it can match any string.
If the right parenthesis in a pattern string has no matching left parenthesis, the right parenthesis is used as a common character.
If the left parenthesis in a pattern string has no matching right parenthesis, the pattern string is invalid.
100(200)+ matches 100200, 100200200, and so on.
(ab) matches abcab.
() can match any string.
a()b matches 12ab12.
a)b matches za)bc.
a(b is an invalid pattern string.
_
Matches regular expressions with a sign, such as a comma (,), left brace ({), right brace (}), left parenthesis ((), right parenthesis ()), or space. In addition, the underscore (_) can be used at the beginning of a regular expression with the same function as the caret (^) or at the end of a regular expression with the same function as the dollar sign ($).
_65001_ matches 20 65001 30, 20 65001, 65001 30, 65001, and so on.
x|y
Matches x or y.
100|200 matches 100 or 200.
1(2|3)4 matches 124 or 134, rather than 1234, 14, 1224, and 1334.
[xyz]
Matches any character contained in a regular expression. It cannot simultaneously match multiple characters or match the same character multiple times.
[123] matches 2 in 255.
[abc] matches characters a, b, and c.
[^xyz]
Matches characters excluding x, y, and z in a character string. That is, it matches any string with at least one character that is not x, y, or z.
[^123] matches any character except 1, 2, and 3.
[^abc] matches any character except a, b, and c.
[a-z]
Matches any character within a specified range. It cannot simultaneously match multiple characters or match the same character multiple times.
[0-9] matches any digit within the range of 0 to 9.
[a-z] matches any letter from a to z.
[z-a] is an invalid pattern string.
[^a-d]
Matches all characters except a, b, c, and d in a character string. That is, it matches any string with at least one character that is beyond the range of a to d.
[^0-9] matches all non-digit characters.
[^a-z] matches all non-letter characters.
[^z-a] is an invalid pattern string.
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 escape character \ match themselves.
Special characters * and + placed at the beginning of a regular expression. For example, +45 matches "+45" and abc(*def) matches "abc*def".
Special character ^ placed in a non-start position of a regular expression For example, abc^ matches "abc^".
Special character $ placed in a non-end position of a regular expression For example, 12$2 matches "12$2".
A right parenthesis ) or right bracket ] alone. For example, abc) matches "abc)" and 0-9] matches "0-9]".
Unless otherwise specified, degeneration rules also apply when the preceding regular expressions are sub-regular expressions within parentheses.
Combination of common and special characters
In actual usage, regular expressions combine multiple common and special characters to match certain strings.
Specifying a Filtering Mode in a Command
When a character string is used to filter command output information, the first line of the output starts from the line where certain information matches the character string, not from the matched information.
The system allows you to use | count to display the number of lines, | section to display the command output by section, | ignore-case to match a string of case-insensitive characters, and | no-more to display filtered output information on only one screen. | count and | section can be used with the following filtering modes or used independently. | ignore-case and | no-more must be used 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 command output information until the information matches the specified case-sensitive character string is displayed. The output following the certain information that matches the character string will be displayed on the screen.
| exclude regular-expression: displays all the lines that do not match the regular expression.
If the character strings to be output 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 output 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.
The command output can be filtered by multiple regular expressions, which take effect in configuration sequence. A maximum of 32 regular expressions can be configured to filter the command output.
| section is used to display only the commands with section information in the output, such as the display current-configuration and display this commands.
The following examples describe how to specify a filter mode in a command.
Example 1: Run the display pm brief command to display all the lines that do not match the regular expression Directory|Files. Directory|Files matches directories or files.
<HUAWEI> display pm brief | exclude Directory|Files
Statistics Status : disable
Statistics Start Time : -
Current Statistics Cycles : -
Number of Statistics Tasks : 0
Number of Statistics Objects : 0
Number of Configured Pm Servers : 0
Example 2: Use the vlan regular expression to filter the display current-configuration command output.
<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
Example 3: Use the vlan regular expression to filter the display current-configuration command output.
<HUAWEI> display current-configuration | include vlan | count
Total lines: 14.
The preceding information is used for reference only.
- If the interval is too short, the CPU usage will increase. Set the interval to a proper value.
- If the number of available VTY channels on a device is less than 3, | refresh cannot be used.
- Only display commands can be queried using | refresh.
> filename
The output is saved to a specified file. If the target file already exists, the original content of the file is overwritten.
>> filename
The output is appended to a specified file, and the original content of the file remains unchanged.
Configuring the Session Logging Function
Context
By default, the global session logging function is disabled. To save the command input, command output, and command execution time to the sessionlog file in the root directory, you can enable the global session logging function.
By default, the session logging function for a single connection is enabled. After the global session logging function is enabled, the input and output information of all connections on a device is recorded in log files. If some connections do not require session logs, you can run a command to disable the session logging function for those connections.
You can run the display info-center session log status command to check the status of the global session logging function and the session logging function for all online connections.
Procedure
- Enable the global session logging function.
system-view undo info-center session log disable commit
- Disable the session logging function for the current connection.
system-view terminal session-log disable commit
If the global session logging function is disabled, the session logging function of the current connection is also disabled. In this case, you do not need to perform the preceding operations.
- How to Use the CLI
- Entering Command Views
- Selecting a Mode for the Configuration to Take Effect
- Disabling the Re-confirmation Function
- Intelligent Command Backtracking
- Setting Command Privilege Levels
- Editing Command Lines
- Using Command Online Help
- Interpreting Command Error Messages
- Using an undo Command
- Displaying Historical Commands
- Using Command Line Shortcut Keys
- Configuring an Alias for a Command
- Replacing Characters
- Running User View Commands in the System View
- Configuring the Command Timestamp
- Enabling Secondary Authentication
- Displaying the Command Output
- Configuring the Session Logging Function