Freebie

IOS CLI

Cisco IOS organizes configuration into a hierarchy of modes, described below. Use exit to move up one level and end (or Ctrl+Z) to return directly to Privileged EXEC from any configuration mode.

Modes

Cisco IOS has the following modes:

ModePromptDescription
User EXEC mode>The first mode you reach after connecting to the device. It gives limited, read-only access to device status.
Privileged EXEC mode, also called enable mode#Reached by running enable from User EXEC mode. It gives full read access to device state and is required before you can enter configuration mode.
Global configuration mode(config)#Reached by running configure terminal from Privileged EXEC mode. Device-wide settings, like the hostname and routing protocols, live here.
Interface configuration mode(config-if)#A sub-mode of global config that controls a specific physical or logical port, for example its speed, IP address, or shutdown state.
Line configuration mode(config-line)#A sub-mode of global config that controls an access line used to connect to the device: the console port, VTY lines (SSH/Telnet), or the AUX port.
Router configuration mode(config-router)#A sub-mode of global config that controls a specific routing protocol process, such as OSPF.

Enter mode

Each mode has its own command to enter it, run from the mode one level above.

ModeCommand
User EXEC(connect)
Privileged EXECenable
Global configurationconfigure terminal
Interface configurationinterface type port-number
Line configurationline console 0
line vty first last
line aux 0
Router configurationrouter ospf process-id

User EXEC

Use this mode for quick, non-privileged checks, like confirming the device is reachable, without risking any configuration changes.

User EXEC is the least-privileged mode in the IOS command hierarchy. It lets you run basic commands that display the device’s configuration and status.

CCNA tip

Learning the available show commands and how to interpret their output is a major part of studying for the CCNA.

CommandDescription
enableEnters Privileged EXEC mode
quitCloses the current session

Privileged EXEC

Use this mode when you need full visibility into device state, such as the running configuration or hardware details, or when you need to run operational commands like reload and copy before entering configuration mode.

  • Privileged EXEC gives unlimited access to the available show commands and to many other commands that control device features.
  • Privileged EXEC also lets you enter global configuration mode and change the configuration. Protect it with a password. For details, see Privileged EXEC passwords.
  • Neither EXEC mode changes the configuration. Both modes only let you view the device’s status and configuration and run operational commands, such as restarting the device, saving the configuration, and moving and deleting files.
CommandDescription
disableReturns to User EXEC mode
configure terminalEnters global configuration mode
no debug allDisables all active debug sessions
undebug allAlias for no debug all
reloadReboots the device
copy running-config startup-configSaves running config to NVRAM
writeAlias for copy running-config startup-config
write memoryAlias for copy running-config startup-config
copy startup-config running-configLoads startup config into running config
show running-configDisplays the current running configuration
show startup-configDisplays the saved startup configuration
write eraseErases the startup configuration from NVRAM
erase startup-configAlias for write erase
erase nvram:Erases all NVRAM contents
show mac address-tableDisplays the MAC address table (switches only)
quitCloses the current session

Global configuration

Use this mode to change settings that apply to the whole device, such as the hostname and passwords, or as your entry point into a more specific sub-mode like an interface, line, or routing process.

  • Configure a unique hostname on each device so the devices are easy to identify.
  • To undo a configuration command, put no in front of it.
  • To run an EXEC mode command from a configuration mode, put do in front of it. You don’t have to return to Privileged EXEC first.
CommandDescription
line console 0Enters line config mode for the console; subsequent commands apply only to the console line
line vty first lastEnters line config mode for remote access lines
interface type port-numberEnters interface config mode for the specified port
router ospf process-idEnters router config mode for an OSPF process
hostname nameSets the device hostname
enable password passwordSets the enable password (legacy)
enable secret passwordSets the enable secret, stored as a hash
service password-encryptionEncrypts current and future passwords with type 7 encryption
no commandUndoes a configuration command
do commandRuns an EXEC mode command from a configuration mode
exitMoves up one level in the config hierarchy
endReturns directly to Privileged EXEC
Ctrl+ZRuns the partially typed command, then returns to Privileged EXEC
Ctrl+CReturns to Privileged EXEC without running the partially typed command

Ctrl+Z vs. Ctrl+C

If you press Ctrl+Z in the middle of typing a command, the device runs the typed command before it returns to Privileged EXEC. This is equivalent to pressing Enter and then running end. Ctrl+C doesn’t run the command. It only returns you to Privileged EXEC.

Interface configuration

Use this mode to change settings scoped to one physical or logical port, such as its IP address, speed, or shutdown state.

CommandDescription
speed valueHard-sets interface speed; disables autonegotiation
exitMoves up one level in the config hierarchy
endReturns directly to Privileged EXEC
Ctrl+ZReturns directly to Privileged EXEC

Line configuration

Use this mode to control how administrators connect to the device itself, such as setting console or VTY passwords, not how the device forwards traffic.

CommandDescription
loginTells IOS to perform simple password checking on the line
password passwordSets the plain-text password for the line
exitMoves up one level in the config hierarchy
endReturns directly to Privileged EXEC
Ctrl+ZReturns directly to Privileged EXEC

Router configuration

Use this mode to enable or tune a specific routing protocol instance, such as advertising networks into OSPF.

CommandDescription
exitMoves up one level in the config hierarchy
endReturns directly to Privileged EXEC
Ctrl+ZReturns directly to Privileged EXEC

Help commands

IOS provides context-sensitive help so you don’t have to memorize every command and keyword.

SyntaxDescription
?Lists every command available in the current EXEC or configuration mode
command ?Lists the keywords or arguments that command accepts
com?Lists every command that starts with com (no space before ?)
comTabCompletes the command if only one command starts with com
comEnterRuns the command if only one command starts with com
command parm?Lists the keywords for command that start with parm (no space before ?)
command parmTabCompletes parm if it uniquely matches one keyword
command parm1 ?Lists the keywords available after parm1

<cr> in help output means carriage return, which refers to the Enter key. It means you can press Enter to run the command as typed. For example, show clock is a valid command on its own, even though the detail keyword is available.

Keyboard shortcuts

ShortcutDescription
Ctrl+AMoves the cursor to the beginning of the current command
Ctrl+EMoves the cursor to the end of the current command
Ctrl+UDeletes all characters to the left of the cursor

Filter show output

A pipe (|) filters the output of a show command. The include keyword after a pipe shows only the lines that include the characters you specify:

R1# show running-config | include enable
enable password ccna

Device access

You can access the IOS CLI in two ways:

  • Console: Connect a PC or laptop to the device’s console port with a console cable.
  • Network: Connect to the device over the network with a protocol like Telnet or Secure Shell (SSH).

Console ports

The console port type depends on the device model. USB Mini-B and RJ45 console ports are common across many Cisco router and switch models.

To connect to an RJ45 console port, you must use a rollover cable. A rollover cable reverses the pin order from one end to the other:

End A pinEnd B pin
18
27
36
45
54
63
72
81

Terminal emulator settings

When you connect a terminal emulator on a PC to a device’s console port, configure these settings:

SettingCisco defaultDescription
Speed9600 bpsThe rate at which data is sent
Data bits8The number of bits used for each character of text sent to the device
Stop bits1Sent after every character so the receiving device can detect the end of it
ParityNoneAn extra bit sent with each character for error detection
Flow controlNoneHandles cases where a device sends data faster than the receiver can process it

Configuration files

IOS stores the device configuration in two text files. The files are stored in different hardware memory and serve different purposes:

running-configstartup-config
PurposeDetermines the device’s current operationLoaded by the device when it boots
Stored inRandom-access memory (RAM)Nonvolatile RAM (NVRAM), a special type of RAM
View withshow running-configshow startup-config

When the device boots, it copies the contents of startup-config to running-config in RAM.

Save the configuration

To save changes to running-config, copy running-config to startup-config. Otherwise, the device loses those changes when it reboots. It boots with the last saved startup-config, or with a factory-default configuration if no startup-config exists. A new device that boots for the first time has no startup-config file until you run one of these commands:

  • write
  • write memory
  • copy running-config startup-config

Restore the factory-default configuration

To return a device to its factory-default configuration, erase startup-config with one of these commands, then restart the device with reload:

  • write erase
  • erase nvram:
  • erase startup-config

Privileged EXEC passwords

Privileged EXEC mode lets a user enter global configuration mode and change the device configuration. Configure a password to prevent unauthorized users from accessing privileged EXEC mode.

Enable password

The enable password is a password you must enter to access privileged EXEC mode. The enable password is a legacy feature.

R1(config)# enable password ccna
R1(config)# exit
R1# disable
R1> enable
Password:
R1#

To verify the password, filter the running configuration:

R1# show running-config | include enable
enable password ccna

Encrypt passwords

To improve the security of the enable password, run service password-encryption in global configuration mode. The command encrypts all current passwords on the device and all passwords you configure in the future. It uses type 7 encryption.

R1(config)# service password-encryption
R1(config)# do show running-config | include enable
enable password 7 0307580507

To undo the encryption, run no service password-encryption:

  • Currently encrypted passwords stay encrypted.
  • Future passwords aren’t encrypted.

Enable secret

The enable secret is a more secure password. IOS stores it as a hash, rather than as encrypted ciphertext. Hashing is a one-way function. You can’t reverse a hash to recover the original password.

R1(config)# enable secret cisco
R1(config)# do show running-config | include enable
enable secret 9 $9$emuJQV5sVZCY8v$INbrp9XrtfWHieMubzYt7N640m4KXDIqKg/a6SHY9lU
enable password 7 0307580507
  • If you configure both the enable password and the enable secret, only the enable secret works. The enable password stays in the configuration, but you can’t use it to access privileged EXEC mode.
  • The hashing algorithm is scrypt (pronounced S-crypt), also called type 9. The 9 before the hash indicates the type.
  • On many older devices, the default algorithm is Message Digest 5 (MD5), also called type 5. Type 5 isn’t as secure as type 9, so use type 9.