![]() |
Table Of Contents
Using the Command-Line Interface in Cisco IOS Software
Initially Configuring a Device
Using the Interactive Help Feature
Understanding Enable and Enable Secret Passwords
Using the Command History Feature
Using Aliases for CLI Commands
Using the no and default Forms of Commands
Filtering Output Using Output Modifiers
Understanding CLI Error Messages
Saving Changes to a Configuration
Using the Command-Line Interface in Cisco IOS Software
Last Updated: February 24, 2010
This document provides basic information about the command-line interface (CLI) in Cisco IOS software and how you can use some of the CLI features. This document contains the following sections:
•
Initially Configuring a Device
•
Saving Changes to a Configuration
For more information about using the CLI, see the "Using the Cisco IOS Command-Line Interface" section of the Cisco IOS Configuration Fundamentals Configuration Guide.
For information about the software documentation set, see the "About Cisco IOS 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/Technologies 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 changes that you can make to a console port and 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:
•
Using the Interactive Help Feature
•
Understanding Enable and Enable Secret Passwords
•
Using the Command History Feature
•
Using Aliases for CLI Commands
•
Using the no and default Forms of Commands
•
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 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 commandboot boot up an external processconfreg configuration register utilitycont continue executing a downloaded imagecontext display the context of a loaded imagecookie 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 2 describes the purpose of the CLI interactive Help commands.
The following examples show how to use the help commands:
help
Router> help
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# ?
Exec commands:access-enable Create a temporary access-List entryaccess-profile Apply user-profile to interfaceaccess-template Create a temporary access-List entryalps ALPS exec commandsarchive manage archive files<snip>partial command?
Router(config)# zo?
zone zone-pairpartial command<Tab>
Router(config)# we<Tab> webvpncommand ?
Router(config-if)# pppoe ?
enable Enable pppoemax-sessions Maximum PPPOE sessionscommand keyword ?
Router(config-if)# pppoe enable ?
group attach a BBA group<cr>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 3 describes these conventions.
The following examples show syntax conventions:
Router(config)# ethernet cfm domain ?
WORD domain nameRouter(config)# ethernet cfm domain dname ?
levelRouter(config)# ethernet cfm domain dname level ?
<0-7> maintenance level numberRouter(config)# ethernet cfm domain dname level 7 ?
<cr>Router(config)# snmp-server file-transfer access-group 10 ?
protocol protocol options<cr>Router(config)# logging host ?
Hostname or A.B.C.D IP address of the syslog serveripv6 Configure IPv6 syslog serverUnderstanding 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:
•
enable password
•
enable secret password
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 numeral. 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 numeral 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.shtmlUsing the Command History Feature
The command history feature saves, in a command history buffer, the commands that you enter during a session. The default number of saved commands 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 numA 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. (Command and keyword examples are from Cisco IOS Release 12.4(13)T.)
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 4 shows the default command aliases.
Table 4 Default Command Aliases
Command Alias Original Commandh
help
lo
logout
p
ping
s
show
u or un
undebug
w
where
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 the following:
http://www.cisco.com/en/US/docs/ios/fundamentals/command/reference/cf_a1.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 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:
http://www.cisco.com/en/US/docs/ios/debug/command/reference/db_book.html
CautionDebugging is a high priority and high CPU utilization process that can render your device unusable. Use debug commands only to troubleshoot specific problems. The best times to run debugging are during periods of low network traffic and when few users are interacting with the network. Debugging during these periods decreases the likelihood that the debug command processing overhead will affect network performance or user access or response times.
Filtering Output Using Output Modifiers
Many commands produce lengthy output that may use several screens to display. Using output modifiers, you can 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."
Router# show interface | include protocolFastEthernet0/0 is up, line protocol is upSerial4/0 is up, line protocol is upSerial4/1 is up, line protocol is upSerial4/2 is administratively down, line protocol is downSerial4/3 is administratively down, line protocol is downUnderstanding CLI Error Messages
You may encounter some error messages while using the CLI. Table 5 shows the common CLI error messages.
For more system error messages, see the Cisco IOS Release 12.4T System Message Guide.
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:
Router# copy running-config startup-configDestination filename [startup-config]?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.
Building configuration...[OK]Router#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
•
"Using the Cisco IOS Command-Line Interface" section of the Cisco IOS Configuration Fundamentals Configuration Guide
http://www.cisco.com/en/US/docs/ios/fundamentals/configuration/guide/cf_cli-basics.html
•
Cisco Product/Technology Support
http://www.cisco.com/go/techdocs
•
Support area on Cisco.com (also search for documentation by task or product)
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/public/sw-center/
•
Error Message Decoder, a tool to help you research and resolve error messages for Cisco IOS software
http://www.cisco.com/pcgi-bin/Support/Errordecoder/index.cgi
•
Command Lookup Tool, a tool to help you find detailed descriptions of Cisco IOS commands (requires Cisco.com user ID and password)
http://tools.cisco.com/Support/CLILookup
•
Output Interpreter, a troubleshooting tool that analyzes command output of supported show commands
https://www.cisco.com/pcgi-bin/Support/OutputInterpreter/home.pl
CCDE, CCENT, CCSI, Cisco Eos, Cisco Explorer, Cisco HealthPresence, Cisco IronPort, the Cisco logo, Cisco Nurse Connect, Cisco Pulse, Cisco SensorBase, Cisco StackPower, Cisco StadiumVision, Cisco TelePresence, Cisco TrustSec, Cisco Unified Computing System, Cisco WebEx, DCE, Flip Channels, Flip for Good, Flip Mino, Flipshare (Design), Flip Ultra, Flip Video, Flip Video (Design), Instant Broadband, and Welcome to the Human Network are trademarks; Changing the Way We Work, Live, Play, and Learn, Cisco Capital, Cisco Capital (Design), Cisco:Financed (Stylized), Cisco Store, Flip Gift Card, and One Million Acts of Green are service marks; and Access Registrar, Aironet, AllTouch, AsyncOS, Bringing the Meeting To You, Catalyst, CCDA, CCDP, CCIE, CCIP, CCNA, CCNP, CCSP, CCVP, Cisco, the Cisco Certified Internetwork Expert logo, Cisco IOS, Cisco Lumin, Cisco Nexus, Cisco Press, Cisco Systems, Cisco Systems Capital, the Cisco Systems logo, Cisco Unity, Collaboration Without Limitation, Continuum, EtherFast, EtherSwitch, Event Center, Explorer, Follow Me Browsing, GainMaker, iLYNX, IOS, iPhone, IronPort, the IronPort logo, Laser Link, LightStream, Linksys, MeetingPlace, MeetingPlace Chime Sound, MGX, Networkers, Networking Academy, PCNow, PIX, PowerKEY, PowerPanels, PowerTV, PowerTV (Design), PowerVu, Prisma, ProConnect, ROSA, SenderBase, SMARTnet, Spectrum Expert, StackWise, WebEx, and the WebEx logo are registered trademarks of Cisco and/or its affiliates in the United States and certain other countries.
All other trademarks mentioned in this document or website are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1002R)
Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.
© 2008-2010 Cisco Systems, Inc. All rights reserved.