Return to InfoBlast Home

Cisco IOS Command Line Interface Tutorial


Abstract

The focus of this document is to introduce a new Cisco Internetworking Operating System (IOS) user to the IOS command line interface (CLI). After reading this document, a new user will understand how to use the IOS CLI to configure and manage an IOS router. For easier reference, Table 1 displays a collection of important terms and acronyms that are used throughout the document.

Table 1 - Glossary Of Important Terms And Acronyms Used In This Tutorial

Cisco IOS - Cisco Internetworking Operating System
CLI - Command Line Interface
EXEC - Command line session to the router (could be console, modem, or telnet)
Flash - Non-Volatile Memory used to store IOS software image
NVRAM - Non-Volatile RAM used to store router configuration
RAM - Random Access Memory

CLI Architecture

A Cisco IOS router command line interface can be accessed through either a console connection, modem connection, or a telnet session. Regardless of which connection method is used, access to the IOS command line interface is generally referred to as an EXEC session.

As a security feature, Cisco IOS separates EXEC sessions into two different access levels - user EXEC level and privileged EXEC level. User EXEC level allows a person to access only a limited amount of basic monitoring commands. Privileged EXEC level allows a person to access all router commands (e.g. configuration and management) and can be password protected to allow only authorized users the ability to configure or maintain the router.

For example, when an EXEC session is started, the router will display a "Router>" prompt. The right arrow (>) in the prompt indicates that the router is at the user EXEC level. The user EXEC level does not contain any commands that might control (e.g. reload or configure) the operation of the router. To list the commands available at the user EXEC level, type a question mark (?) at the Router> prompt. (This feature is referred to as context sensitive help.)

Critical commands (e.g. configuration and management) require that the user be at the privileged EXEC level. To change to the privileged EXEC level, type "enable" at the Router> prompt. If an enable password is configured, the router will then prompt for that password. When the correct enable password is entered, the router prompt will change to "Router#" indicating that the user is now at the privileged EXEC level. To switch back to user EXEC level, type "disable" at the Router# prompt. Typing a question mark (?) at the privileged EXEC level will now reveal many more command options than those available at the user EXEC level. The text below illustrates the process of changing EXEC levels.

Router> enable
Password: [enable password]
Router# disable
Router>

Note: For security reasons, the router will not echo the password that is entered. Also, be advised that if configuring a router via telnet, the password is sent in clear text. Telnet does not offer a method to secure packets.

Once an EXEC session is established, commands within Cisco IOS are hierarchically structured. In order to successfully configure the router, it is important to understand this hierarchy. To illustrate this hierarchy, Figure 1 provides a simple high-level schematic diagram of some IOS commands.

Figure 1 - IOS CLI hierarchy

Command options and applications vary depending on position within this hierarchy. Referring to the diagram in figure 1, configuration command options will not be available until the user has navigated to the configuration branch of the IOS CLI structure. Once in the configuration branch, a user may enter system level configuration commands that apply to the entire router at the global configuration level. Interface specific configuration commands are available once the user has switched to the particular interface configuration level. More detailed information and examples on how to navigate through the IOS CLI hierarchy are offered in the Router Configuration section.

To assist users in navigation through IOS CLI, the command prompt will change to reflect the position of a user within the command hierarchy. This allows users to easily identify where within the command structure they are at any given moment. Table 2 is a summary of command prompts and the corresponding location within the command structure.

Table 2 - IOS Command Prompt Summary

Router> - User EXEC mode
Router# - Privileged EXEC mode
Router(config)# - Configuration mode (notice the # sign indicates this is only accessible at privileged EXEC mode.)
Router(config-if)# - Interface level within configuration mode.
Router(config-router)# - Routing engine level within configuration mode.
Router(config-line)# - Line level (vty, tty, async) within configuration mode.

CLI Editor Features

Context Sensitive Help

Cisco IOS CLI offers context sensitive help. This is a useful tool for a new user because at any time during an EXEC session, a user can type a question mark (?) to get help. Two types of context sensitive help are available - word help and command syntax help.

Word help can be used to obtain a list of commands that begin with a particular character sequence. To use word help, type in the characters in question followed immediately by the question mark (?). Do not include a space before the question mark. The router will then display a list of commands that start with the characters that were entered. The following is an example of word help:

Router# co?
configure connect copy

Command syntax help can be used to obtain a list of command, keyword, or argument options that are available based on the syntax the user has already entered. To use command syntax help, enter a question mark (?) in the place of a keyword or argument. Include a space before the question mark. The router will then display a list of available command options with <cr> standing for carriage return. The following is an example of command syntax help:

Router# configure ?
  memory             Configure from NV memory
  network            Configure from a TFTP network host
  overwrite-network  Overwrite NV memory from TFTP network host 
  terminal           Configure from the terminal
  <cr>

Command Syntax Check

If a command is entered improperly (e.g. typo or invalid command option), the router will inform the user and indicate where the error has occurred. A caret symbol (^) will appear underneath the incorrect command, keyword, or argument. The following example displays what happens if the keyword "ethernet" is spelled incorrectly.

Router(config)#interface ethernat
                               ^
% Invalid input detected at '^' marker.

Command Abbreviation

Commands and keywords can be abbreviated to the minimum number of characters that identifies a unique selection. For example, you can abbreviate the "configure" command to "conf" because "configure" is the only command that begins with "conf". You could not abbreviate the command to "con" because more than one command could fit this criteria. The router will issue the following error message if you do not supply enough characters.

cisco(config)#i
% Ambiguous command:  "i"

Hot Keys

For many editing functions, the IOS CLI editor provides hot keys. The following table lists some editing shortcuts that are available.

Table 3 - Summary Of Hot Keys

Delete - Removes one character to the right of the cursor.
Backspace - Removes one character to the left of the cursor.
TAB - Finishes a partial command.
Ctrl-A - Moves the cursor to the beginning of the current line.
Ctrl-R - Redisplays a line.
Ctrl-U - Erases a line.
Ctrl-W - Erases a word.
Ctrl-Z - Ends configuration mode and returns to the EXEC.
Up Arrow - Allows user to scroll forward through former commands.
Down Arrow - Allows user to scroll backward through former commands.

Router Configuration

Entering Configurations

Perhaps the best way to illustrate IOS CLI navigation is by walking through a simple router configuration. The comments in the example do not attempt to explain the meaning of each individual command, but rather intend to display where configuration commands are entered within the IOS command structure. Pay particular attention to how the command prompt changes as the user navigates through the IOS CLI hierarchy. Also notice that global parameters are configured at the global configuration level (indicated by the "Router(config)#" prompt) whereas interface specific commands are entered after switching to the particular interface (indicated by the "Router(config-if)#" prompt). Global parameters and interface parameters are discussed further in the Displaying Configurations section under Router Management.

Router> enable - switches to privileged EXEC level
Router# configure terminal - switches to global configuration level
Router(config)# enable secret cisco - configures router with an enable secret (global)
Router(config)# ip route 0.0.0.0 0.0.0.0 20.2.2.3 - configures a static IP route (global)
Router(config)# interface ethernet0 - switches to configure the ethernet0 interface
Router(config-if)# ip address 10.1.1.1 255.0.0.0 - configures an IP address on ethernet0 (interface)
Router(config-if)# no shutdown - activates ethernet0 (interface)
Router(config-if)# exit - exits back to global configuration level
Router(config)# interface serial0 - switches to configure the serial0 interface
Router(config-if)# ip address 20.2.2.2 255.0.0.0 - configures an IP address on serial0 (interface)
Router(config-if)# no shutdown - activates serial0 (interface)
Router(config-if)# exit - exits back to global configuration level
Router(config)# router rip - switches to configure RIP routing engine
Router(config-router)# network 10.0.0.0 - adds network 10.0.0.0 to RIP engine (routing engine)
Router(config-router)# network 20.0.0.0 - adds network 20.0.0.0 to RIP engine (routing engine)
Router(config-router)# exit - exits back to global configuration level
Router(config)# exit - exits out of configuration level
Router# copy running-config startup-config - saves configuration into NVRAM
Router# disable - disables privileged EXEC level
Router> - indicates user is back to user EXEC level

In the above example, notice how the exit command is used to back up a level within the IOS hierarchy. For example, if in the interface configuration level (i.e. Router (config-if)# prompt), typing exit will put the user back in the global configuration level (i.e. Router (config)# prompt).

Taking Interfaces Out Of Shutdown

Routers ship from the factory with all interfaces deactivated. Deactivated interfaces are referred to as being in a shutdown state. Before an interface can be used, it must be taken out of the shutdown state. To take an interface out of shutdown, type "no shutdown" at the appropriate interface configuration level. The example above includes these commands for both the ethernet and serial interfaces.

Removing Commands / Resetting Default Values

IOS provides an easy way to remove commands from a configuration. To remove a command from the configuration, simply navigate to the proper location and type "no" followed by the command to be removed. The following example displays how to remove an IP address from the ethernet0 interface.

Router> enable - switches to privileged EXEC level
Router# configure terminal - switches to global configuration level
Router(config)# interface ethernet0 - switches to configure the ethernet0 interface
Router(config-if)# no ip address - removes IP address
Router(config-if)# exit - exits back to global configuration level
Router(config)# exit - exits out of configuration level
Router# disable - disables privileged EXEC level
Router> - prompt indicates user is back to user EXEC level

Some configuration commands in IOS are enabled by default and assigned a certain default value. When left at the default value, these commands will not be displayed when the configuration is listed. If the value is altered from the default setting, issuing a "no" form of the command will restore the value to the default setting.

Saving Configurations

A Cisco IOS router stores configurations in two locations - RAM and NVRAM. The running configuration is stored in RAM and is used by the router during operation. Any configuration changes to the router are made to the running-configuration and take effect immediately after the command is entered. The startup-configuration is saved in NVRAM and is loaded into the router's running-configuration when the router boots up. If a router loses power or is reloaded, changes to the running configuration will be lost unless they are saved to the startup-configuration. To save the running-configuration to the startup configuration, type the following from privileged EXEC mode (i.e. at the "Router#" prompt.)

Router# copy running-config startup-config

Note: Prior to 11.x software, the command to save the running-configuration to the startup-configuration was different. Use the following command if your IOS version is prior to 11.x:

Router#write memory

IMPORTANT: When editing a configuration, SAVE the configuration often!


Router Management

IOS supports many different types of show commands. This section covers a few of the common show commands used to both manage and troubleshoot a router. The scope of this document is not to instruct how to use these commands to troubleshoot a router, but to make the user aware that these management options exist. For specific information about troubleshooting a network using these commands, refer to the appropriate troubleshooting document.

Displaying Configurations

To display the running-configuration, type the following command in privileged EXEC mode:

Router#show running-config

To display the startup-configuration that is stored in NVRAM, type the following command in privileged EXEC mode:

Router#show startup-config

The following is the show running-config output from the example used in the Router Configuration section.

Current configuration:
!
version 11.2
!
hostname cisco
!
enable password cisco
!
interface Ethernet0
 ip address 10.1.1.1 255.0.0.0
!
interface Serial0
 ip address 20.2.2.2 255.0.0.0
!
router rip
 network 10.0.0.0
 network 20.0.0.0
!
ip route 0.0.0.0 0.0.0.0 20.2.2.3
!
line vty 0 4
 password telnet
 login
!
end

When displaying a configuration, the exclamation marks (!) function as line separators to make reading easier. Referring to the above example, notice how commands entered at the interface configuration level appear indented underneath the respective interface (e.g. interface Ethernet0). Likewise, commands entered underneath the routing engine configuration level appear indented underneath the routing engine (e.g. router rip). Global level commands are not indented. This type of display allows a user to easily identify which configuration parameters are set at the global configuration level and which are set at the various configuration sub-levels.

Note: If an interface was in a shutdown state, the word 'shutdown' would appear indented under the particular interface in shutdown state. Also, commands that are enabled by default are not displayed in the configuration listing.

Displaying Software Version And More

The show version command provides a lot of information in addition to the version of software that is running on the router. The following information can be collected with the show version command:

Software Version - IOS software version (stored in flash)
Bootstrap Version - Bootstrap version (stored in Boot ROM)
System up-time - Time since last reboot
System restart info - Method of restart (e.g. power cycle, crash)
Software image name - IOS filename stored in flash
Router Type and Processor type - Model number and processor type
Memory type and allocation (Shared/Main) - Main = Processor RAM
- Shared = Packet I/O buffering
Software Features - Supported protocols / feature sets
Hardware Interfaces - Interfaces available on router
Configuration Register - Bootup specifications, console speed setting, etc.

The following is a sample output of a show version command.

Router# show version
Cisco Internetwork Operating System Software
IOS (tm) 3600 Software (C3640-J-M), Version 11.2(6)P, SHARED PLATFORM, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-1997 by cisco Systems, Inc.
Compiled Mon 12-May-97 15:07 by tej
Image text-base: 0x600088A0, data-base: 0x6075C000

ROM: System Bootstrap, Version 11.1(7)AX [kuong (7)AX], EARLY DEPLOYMENT RELEASE SOFTWARE (fc2)

Router uptime is 1 week, 1 day, 38 minutes
System restarted by power-on
System image file is "flash:c3640-j-mz_112-6_P.bin", booted via flash
Host configuration file is "3600_4-confg", booted via tftp from 171.69.83.194

cisco 3640 (R4700) processor (revision 0x00) with 107520K/23552K bytes of memory.
Processor board ID 03084730
R4700 processor, Implementation 33, Revision 1.0
Bridging software.
SuperLAT software copyright 1990 by Meridian Technology Corp).
X.25 software, Version 2.0, NET2, BFE and GOSIP compliant.
TN3270 Emulation software.
Primary Rate ISDN software, Version 1.0.
2 Ethernet/IEEE 802.3 interface(s)
97 Serial network interface(s)
4 Channelized T1/PRI port(s)
DRAM configuration is 64 bits wide with parity disabled.
125K bytes of non-volatile configuration memory.
16384K bytes of processor board System flash (Read/Write)

Configuration register is 0x2102

Displaying Interface States

To view information about a particular interface, use the show interface command. The show interface command provides the following list of important information:

Interface State (e.g. UP, DOWN, LOOPED)
Protocol addresses
Bandwidth
Reliability and Load
Encapsulation type
Packet Rates
Error Rates
Signaling Status (i.e. DCD,DSR,DTR,RTS,CTS)

The following is an example of a "show interface serial0" output:

Router#show interface serial 0
Serial0 is up, line protocol is down
Hardware is QUICC Serial
Internet address is 10.1.1.2/24
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, rely 255/255, load 1/255
Encapsulation FRAME-RELAY, loopback not set, keepalive set (10 sec)
LMI enq sent 207603, LMI stat recvd 113715, LMI upd recvd 0, DTE LMI down
LMI enq recvd 0, LMI stat sent 0, LMI upd sent 0
LMI DLCI 1023 LMI type is CISCO frame relay DTE
Broadcast queue 0/64, broadcasts sent/dropped 0/0, interface broadcasts 62856
Last input 1w3d, output 00:00:08, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0 (size/max/drops); Total output drops: 0
Queueing strategy: weighted fair
Output queue: 0/64/0 (size/threshold/drops)
Conversations 0/1 (active/max active)
Reserved Conversations 0/0 (allocated/max allocated)
5 minute input rate 1000 bits/sec, 1 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
1012272 packets input, 91255488 bytes, 0 no buffer
Received 916 broadcasts, 0 runts, 0 giants
18519 input errors, 0 CRC, 17796 frame, 0 overrun, 0 ignored, 723 abort
283132 packets output, 13712011 bytes, 0 underruns
0 output errors, 0 collisions, 31317 interface resets
0 output buffer failures, 0 output buffers swapped out
3 carrier transitions
DCD=up DSR=up DTR=up RTS=up CTS=up

All contents copyright © 1992--1999 Cisco Systems, Inc. Important Notices and Privacy Statement.