Two ways in: console and remote access
Cisco IOS (Internetwork Operating System) is the software on Cisco routers and switches. Newer devices run IOS XE, which feels the same at the command line. You reach its CLI (command-line interface) in one of two ways:
- Console port: a direct cable from your laptop to the device (an RJ-45 "rollover" cable with a USB-to-serial adapter, or a USB console cable). It works even when the device has no IP address at all. The usual terminal settings are 9600 baud, 8 data bits, no parity, 1 stop bit, no flow control.
- Remote access over the network with SSH (encrypted, use this) or Telnet (plain text, avoid it). The device needs an IP address, and its VTY lines (virtual terminal lines, the "ports" that remote sessions land on) must be set up. See SSH and Telnet for how the protocols work.
Device key: R1 (router) · SW1 (switch) · Admin PC (computer) · ISP (network / service)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- Admin laptop: console cable
- R1: Gi0/1 192.168.10.1
- SW1: Vlan1 192.168.10.2
- Admin PC: IP 192.168.10.10
- ISP: IP 198.51.100.1
- 1. Day one: the console cable. A direct serial connection. No IP address or network needed, so it works even before anything is configured.
- 2. Later: SSH over the LAN. Once R1 has an address and its VTY lines allow SSH, the admin PC connects across SW1.
- 3. Switches too. SW1 is managed through its own IP address on a VLAN interface (an SVI).
The modes and their prompts
The CLI is split into modes. Each mode allows a different set of commands, and the prompt always tells you which mode you are in. That is the most useful habit to build: read the prompt before you type.
Basic checks. Use enable to request privileged EXEC.
Mode and prompt reference
| Mode | Prompt | Enter with | Used for |
|---|---|---|---|
| User EXEC | R1> | Log in | Basic checks: ping, traceroute, some show commands |
| Privileged EXEC | R1# | enable | Verification and administration: show, copy, reload |
| Global configuration | R1(config)# | configure terminal | Settings that apply to the whole device |
| Interface configuration | R1(config-if)# | interface g0/1 | Settings for one interface |
| Line configuration | R1(config-line)# | line console 0 / line vty 0 4 | Console and remote login settings |
| Router configuration | R1(config-router)# | router ospf 1 | A routing protocol |
These examples use the default privilege levels: user EXEC at level 1 and privileged EXEC at level 15. Login policies can place a user directly in privileged EXEC, and command authorization can restrict which commands that user may run. Read the prompt before typing.
From login to interface mode and back
Typing a global command while in a sub-mode usually works: IOS drops you back to global configuration and runs it. That is handy, but it also means a mistyped interface command can quietly land in the wrong place. Keep an eye on the prompt.
Getting around the CLI quickly
Moving between modes
enable
configure terminal
interface GigabitEthernet0/1
description LAN to SW1 Gi1/0/24
exit
line console 0
logging synchronous
endA full walk down and back up: from user EXEC to interface mode, back to global config, into line mode, then straight back to privileged EXEC.
Getting help
Shortcuts worth knowing
| Key or command | Does |
|---|---|
| Up arrow / Ctrl+P | Previous command in the history buffer |
| Down arrow / Ctrl+N | Next command in the history buffer |
| Ctrl+A / Ctrl+E | Jump to the start / end of the line |
| Ctrl+Z | Leave configuration mode (same as end) |
| Ctrl+Shift+6 | Break out of a running ping, traceroute or DNS lookup |
Space / Enter at --More-- | Next page / next line of long output; use Q to stop |
do <command> | Run an EXEC command (such as do show ip interface brief) from any config mode |
terminal length 0 | Turn off --More-- paging for this session |
You can also shorten any word to the fewest letters that make it unique: conf t, sh ip int br, int g0/1. You will see these abbreviations everywhere, including in exam questions.
Two settings that make life easier
configure terminal
no ip domain-lookup
line console 0
logging synchronous
exec-timeout 15 0
endno ip domain-lookup stops the DNS lookup after a typo. logging synchronous reprints your half-typed line after a log message interrupts it. exec-timeout logs an idle session out after 15 minutes.
On lab devices, many engineers type these lines out of habit before anything else. On production devices, check first whether something relies on DNS lookups from the CLI.
How to verify where you are
The prompt is the first check. When in doubt, two commands confirm your level and what you have typed recently.
R1#show privilege Current privilege level is 15
R1#show history enable configure terminal show ip interface brief show privilege show history
terminal history size.R1#show ip ? access-lists List IP access lists arp IP ARP table dhcp Show items in the DHCP database interface IP interface status and configuration ospf OSPF information protocols IP routing protocol process parameters and statistics route IP routing table ...
show ip, each with a one-line description. The real list is much longer.Reading error messages
These common parser errors help distinguish a typo, an abbreviation and missing arguments.
R1#show ip interface brif ^ % Invalid input detected at '^' marker.
^ points at the first character IOS could not accept. Here "brif" is a typo. You also get this error when the command is fine but you are in the wrong mode, for example configure terminal typed at the R1> prompt.R1#co % Ambiguous command: "co"
configure, connect or copy. Type more letters, or co? to see the choices.R1#show ip % Incomplete command.
? to see what can come next.R1#shwo Translating "shwo"...domain server (255.255.255.255) % Unknown command or computer name, or unable to find computer address
no ip domain-lookup so it doesn't happen again.A blank console, garbage text and refused commands
- Nothing appears on the console. Check the terminal settings (9600 8N1, no flow control), the COM port your adapter uses, and that the cable is in the console port, not the AUX or an Ethernet port. Press Enter a few times.
- Garbage characters on the console. Check for a serial speed or framing mismatch. Use the console settings specified for the device; 9600 8N1 is common.
- A command is rejected that you know is correct. Look at the prompt. You are probably in the wrong mode, such as trying
show running-configfrom user EXEC orip addressin global configuration. - Log messages keep breaking your typing. Add
logging synchronousunder the line you use. - SSH or Telnet is refused. The VTY lines may not have a password or login method, or SSH isn't set up. The Initial switch and router setup lesson covers the line settings.
Test yourself on IOS modes
The prompt shows R1(config-if)#. You type end. What prompt do you see next?
At the R1> prompt you type configure terminal and get '% Invalid input detected'. Why?
You type 'co' and press Enter. IOS replies '% Ambiguous command'. What does that mean?
You are in interface configuration mode and want to check the interface status without leaving. What do you type?
You mistype a single word in privileged EXEC and the router hangs for several seconds with 'Translating...'. What prevents this?