- Initially Configuring a Device
- Using the CLI
- Understanding Command Modes
- Using the Interactive Help Feature
- Understanding Command Syntax
- Understanding Enable and Enable Secret Passwords
- Using the Command History Feature
- Abbreviating Commands
- Using Aliases for CLI Commands
- Using the no and default Forms of Commands
- Using the debug Command
- Filtering Output Using Output Modifiers
- Understanding CLI Error Messages
- Saving Changes to a Configuration
- Additional Information
Using the Command-Line Interface in Cisco IOS XE Software
This chapter provides basic information about the command-line interface (CLI) in Cisco IOS XE software and how you can use some of the CLI features. This document contains the following sections:
- Initially Configuring a Device
- Using the CLI
- Saving Changes to a Configuration
- Additional Information
For more information about using the CLI, see “Part 1: Using the Cisco IOS Command-Line Interface (CLI)” of Cisco IOS XE Configuration Fundamentals Configuration Guide.
For information about the software documentation set, see the “ About Cisco IOS XE Software Documentation” document.
Initially Configuring a Device
Initially configuring a device varies by platform. For information about performing an initial configuration, see the hardware installation documentation that is provided with the original packaging of the product or go to the Product Support area of Cisco.com at http://www.cisco.com/go/techdocs.
After you have performed the initial configuration and connected the device to your network, you can configure the device by using the console port or a remote access method, such as Telnet or Secure Shell (SSH), to access the CLI or by using the configuration method provided on the device, such as Security Device Manager.
Changing the Default Settings for a Console or AUX Port
There are only two settings that you can change on a console port or an AUX port:
- Change the port speed with the config-register 0x command. Changing the port speed is not recommended. The well-known default speed is 9600.
- Change the behavior of the port; for example, by adding a password or changing the timeout value.
Note The AUX port on the Route Processor (RP) installed in a Cisco ASR 1000 series router does not serve any useful customer purpose and should be accessed only under the advisement of a customer support representative.
Using the CLI
This section describes the following topics:
- Understanding Command Modes
- Using the Interactive Help Feature
- Understanding Command Syntax
- Understanding Enable and Enable Secret Passwords
- Using the Command History Feature
- Abbreviating Commands
- Using Aliases for CLI Commands
- Using the no and default Forms of Commands
- Using the debug Command
- Filtering Output Using Output Modifiers
- Understanding CLI Error Messages
Understanding Command Modes
The CLI command mode structure is hierarchical, and each mode supports a set of specific commands. This section describes the most common of the many modes that exist.
Table 1-1 lists common command modes with associated CLI prompts, access and exit methods, and a brief description of how each mode is used.
EXEC commands are not saved when the software reboots. Commands that you issue in a configuration mode can be saved to the startup configuration. If you save the running configuration to the startup configuration, these commands will execute when the software is rebooted. Global configuration mode is the highest level of configuration mode. From global configuration mode, you can enter a variety of other configuration modes, including protocol-specific modes.
ROM monitor mode is a separate mode that is used when the software cannot load properly. If a valid software image is not found when the software boots or if the configuration file is corrupted at startup, the software might enter ROM monitor mode. Use the question symbol (?) to view the commands that you can use while the device is in ROM monitor mode.
rommon 1 >
?
alias set and display aliases command
boot boot up an external process
confreg configuration register utility
cont continue executing a downloaded image
context display the context of a loaded image
cookie display contents of cookie PROM in hex
.
.
.
rommon 2 >
The following example shows how the command prompt changes to indicate a different command mode:
Router>
enable
Router#
configure terminal
Router(config)#
interface ethernet 1/1
Router(config-if)#
ethernet
Router(config-line)#
exit
Router(config)#
end
Router#
Note A keyboard alternative to the end command is Ctrl-Z.
Using the Interactive Help Feature
The CLI includes an interactive Help feature. Table 1-2 describes how to use the Help feature.
The following examples show how to use the help commands:
Help may be requested at any point in a command by entering a question mark '?'. If nothing matches, the help list will be empty and you must backup until entering a '?' shows the available options.
Two styles of help are provided:
1. Full help is available when you are ready to enter a command argument (e.g. 'show ?') and describes each possible argument.
2. Partial help is provided when an abbreviated argument is entered and you want to know what arguments match the input (e.g. 'show pr?'.)
Router(config)#
we<Tab> webvpn
Understanding Command Syntax
Command syntax is the format in which a command should be entered in the CLI. Commands include the name of the command, keywords, and arguments. Keywords are alphanumeric strings that are used literally. Arguments are placeholders for values that a user must supply. Keywords and arguments may be required or optional.
Specific conventions convey information about syntax and command elements. Table 1-3 describes these conventions.
The following examples show syntax conventions:
Understanding Enable and Enable Secret Passwords
Some privileged EXEC commands are used for actions that impact the system, and it is recommended that you set a password for these commands to prevent unauthorized use. Two types of passwords, enable (not encrypted) and enable secret (encrypted), can be set. The following commands set these passwords and are issued in global configuration mode:
Using an enable secret password is recommended because it is encrypted and more secure than the enable password. When you use an enable secret password, text is encrypted (unreadable) before it is written to the config.text file. When you use an enable password, the text is written as entered (readable) to the config.text file.
Each type of password is case sensitive, can contain from 1 to 25 uppercase and lowercase alphanumeric characters, and can start with a number. Spaces are also valid password characters; for example, “two words” is a valid password. Leading spaces are ignored, but trailing spaces are recognized.
Note Both password commands have numeric keywords that are single integer values. If you choose a number for the first character of your password followed by a space, the system will read the number as if it were the numeric keyword and not as part of your password.
When both passwords are set, the enable secret password takes precedence over the enable password.
To remove a password, use the no form of the commands: no enable password or no enable secret password.
For more information about password recovery procedures for Cisco products, see the following:
http://www.cisco.com/en/US/products/sw/iosswrel/ps1831/
products_tech_note09186a00801746e6.shtml
Using the Command History Feature
The command history feature saves the commands that you enter during a session in a command history buffer. The default number of commands saved is 10, but the number is configurable within the range of 0 to 256. This command history feature is particularly useful for recalling long or complex commands.
To change the number of commands saved in the history buffer for a terminal session, issue the terminal history size command:
Router# terminal history size num
A command history buffer is also available in line configuration mode with the same default and configuration options. To set the command history buffer size for a terminal session in line configuration mode, issue the history command:
Router(config-line)# history [size num]
To recall commands from the history buffer, use the following methods:
- Press Ctrl-P or the Up Arrow key—Recalls commands beginning with the most recent command. Repeat the key sequence to recall successively older commands.
- Press Ctrl-N or the Down Arrow key—Recalls the most recent commands in the history buffer after they have been recalled using Ctrl-P or the Up Arrow key. Repeat the key sequence to recall successively more recent commands.
Note The arrow keys function only on ANSI-compatible terminals such as the VT100.
- Issue the show history command in user EXEC or privileged EXEC mode—Lists the most recent commands that you entered. The number of commands that are displayed is determined by the setting of the terminal history size and history commands.
The command history feature is enabled by default. To disable this feature for a terminal session, issue the terminal no history command in user EXEC or privileged EXEC mode or the no history command in line configuration mode.
Abbreviating Commands
Typing a complete command name is not always required for the command to execute. The CLI recognizes an abbreviated command when the abbreviation contains enough characters to uniquely identify the command. For example, the show version command can be abbreviated as sh ver. It cannot be abbreviated as s ver because s could mean show, set, or systat. The sh v abbreviation also is not valid because the show command has vrrp as a keyword in addition to version.
Using Aliases for CLI Commands
To save time and the repetition of entering the same command multiple times, you can use a command alias. An alias can be configured to do anything that can be done at the command line, but an alias cannot move between modes, type in passwords, or perform any interactive functions.
Table 1-4 shows the default command aliases.
|
|
---|---|
To create a command alias, issue the alias command in global configuration mode. The syntax of the command is alias mode command-alias original-command. Following are some examples:
- Router(config)# alias exec prt partition —privileged EXEC mode
- Router(config)# alias configure sb source-bridge —global configuration mode
- Router(config)# alias interface rl rate-limit —interface configuration mode
To view both default and user-created aliases, issue the show alias command.
For more information about the alias command, see http://www.cisco.com/en/US/docs/ios/fundamentals/command/reference/cf_book.html.
Using the no and default Forms of Commands
Most configuration commands have a no form that is used to reset a command to its default value or to disable a feature or function. For example, the ip routing command is enabled by default. To disable this command, you would issue the no ip routing command. To re-enable IP routing, you would issue the ip routing command.
Configuration commands may also have a default form, which returns the command settings to their default values. For commands that are disabled by default, using the default form has the same effect as using the no form of the command. For commands that are enabled by default and have default settings, the default form enables the command and returns the settings to their default values. To see what default commands are available on your system, enter default ? in the appropriate command mode of the command-line interface.
The no form is documented in the command pages of Cisco IOS command references. The default form is generally documented in the command pages only when the default form performs a function different than that of the plain and no forms of the command.
Command pages often include a “Command Default” section as well. The “Command Default” section documents the state of the configuration if the command is not used (for configuration commands) or the outcome of using the command if none of the optional keywords or arguments is specified (for EXEC commands).
Using the debug Command
A debug command produces extensive output that helps you troubleshoot problems in your network. These commands are available for many features and functions within Cisco IOS XE software. Some debug commands are debug all, debug aaa accounting, and debug mpls packets. To use debug commands during a Telnet session with a device, you must first enter the terminal monitor command. To turn off debugging completely, you must enter the undebug all command.
For more information about debug commands, see the Cisco IOS Debug Command Reference at http://www.cisco.com/en/US/docs/ios/debug/command/reference/db_book.html.
Filtering Output Using Output Modifiers
Many commands produce lengthy output that may use several screens to display. You can use output modifiers to filter this output to show only the information that you want to see.
The following three output modifiers are available:
- begin regular-expression —Displays the first line in which a match of the regular expression is found and all lines that follow.
- include regular-expression —Displays all lines in which a match of the regular expression is found.
- exclude regular-expression —Displays all lines except those in which a match of the regular expression is found.
To use one of these output modifiers, type the command followed by the pipe symbol (|), the modifier, and the regular expression that you want to search for or filter. A regular expression is a case-sensitive alphanumeric pattern. It can be a single character or number, a phrase, or a more complex string.
The following example illustrates how to filter output of the show interface command to display only lines that include the expression “protocol.”
Understanding CLI Error Messages
You may encounter some error messages while using the CLI. Table 1-5 shows the common CLI error messages.
For more system error messages, see Cisco IOS XE System Messages.
Saving Changes to a Configuration
To save changes that you made to the configuration of a device, you must issue the copy running-config startup-config command or the copy system:running-config nvram:startup-config command. When you issue these commands, the configuration changes that you made are saved to the startup configuration and saved when the software reloads or power to the device is turned off or interrupted.
The following example shows the syntax of the copy running-config startup-config command:
You press Enter to accept the startup-config filename (the default), or type a new filename and then press Enter to accept that name. The following output is displayed indicating that the configuration was saved:
On most platforms, the configuration is saved to NVRAM. On platforms with a Class A flash file system, the configuration is saved to the location specified by the CONFIG_FILE environment variable. The CONFIG_FILE variable defaults to NVRAM.
Additional Information
- “Part 1: Using the Cisco IOS Command-Line Interface (CLI)” of the Cisco IOS XE Configuration Fundamentals Configuration Guide
http://www.cisco.com/en/US/docs/ios/ios_xe/fundamentals/configuration/guide/2_xe/cf_xe_book.html
“Using Cisco IOS XE Software” chapter of the Cisco ASR 1000 Series Aggregation Services Routers Software Configuration Guide
http://www.cisco.com/en/US/docs/routers/asr1000/configuration/guide/chassis/Using_CLI.html
http://www.cisco.com/go/techdocs
http://www.cisco.com/en/US/support/index.html
- Software Download Center (downloads; tools; licensing, registration, advisory, and general information) (requires Cisco.com user ID and password)
http://www.cisco.com/kobayashi/sw-center/
- Error Message Decoder, a tool to help you research and resolve error messages for Cisco IOS XE software
http://www.cisco.com/cgi-bin/Support/Errordecoder/index.cgi
- Command Lookup Tool, a tool to help you find detailed descriptions of Cisco IOS XE commands (choose Select an index: IOS > Select a release: All IOS Commands) (requires Cisco.com user ID and password)
http://tools.cisco.com/Support/CLILookup
https://www.cisco.com/pcgi-bin/Support/OutputInterpreter/home.pl