Skip to content

Beginner · Ethernet, MAC addresses and the Cisco CLI · topic 10 of 57 · 35 min

The Cisco IOS command line

Explanation

Cisco switches and routers are configured through the IOS command line, over a console cable or SSH. You move through modes: user EXEC (>), privileged EXEC (#), global configuration and interface configuration. Changes go into the running-config in RAM at once, and are lost on reboot unless you copy them to the startup-config in NVRAM.

Why learn the CLI?

Most enterprise network devices are still configured by typing commands. Cisco IOS (Internetwork Operating System) is the most common, and the CCNA exam and most network jobs expect you to use it comfortably. Other vendors have similar command lines, so the skill carries over.

Getting in: console and SSH

A brand-new device has no IP address, so the first time you connect with a console cable from your laptop to the console port (RJ45 or USB), using a terminal program such as PuTTY or Tera Term (9600 baud, 8 data bits, no parity, 1 stop bit). Once the device has an IP address and SSH is set up (covered in the security module), you manage it over the network with SSH. Telnet also works but sends passwords in plain text, so avoid it.

The modes and their prompts

ModePromptHow to get thereWhat you can do
User EXECSwitch>Log inA few basic show commands and ping
Privileged EXECSwitch#enableAll show commands, copy, reload, debug
Global configurationSwitch(config)#configure terminalChange settings for the whole device
Interface configurationSwitch(config-if)#interface g0/1Settings for one port
Line configurationSwitch(config-line)#line console 0 (or line vty 0 15)Settings for console or remote logins

exit goes back one level. end (or Ctrl+Z) jumps straight back to privileged EXEC. disable goes from # back to >.

Help, completion and abbreviations

  • Type ? to list the commands allowed in this mode. Type sh? to see commands starting with sh. Type show ? to see what can follow show.
  • Press Tab to complete a word: conf Tab becomes configure.
  • You can shorten any word as long as it is unique: conf t for configure terminal, sh ip int br for show ip interface brief, wr for write.
  • The up arrow recalls earlier commands.
  • In configuration mode, show commands do not work directly. Put do in front: do show ip interface brief.

Running-config and startup-config

Every command you type in configuration mode takes effect at once and is stored in the running-config, which lives in RAM. RAM is cleared when the device reboots or loses power. The startup-config is stored in NVRAM (non-volatile RAM), which survives a reboot; the device loads it when it starts. So after a good change, save it.

output
Switch# show running-config        ! what the device is doing now (RAM)
Switch# show startup-config        ! what it will load at boot (NVRAM)
Switch# copy running-config startup-config
Destination filename [startup-config]?    ! press Enter
Switch# write memory               ! older shortcut that does the same
Cisco IOS: compare and save the configuration. Text after ! is a comment.

A first configuration

output
Switch> enable
Switch# configure terminal
Switch(config)# hostname SW1-Floor2
SW1-Floor2(config)# enable secret Str0ng!Lab
SW1-Floor2(config)# no ip domain-lookup
SW1-Floor2(config)# line console 0
SW1-Floor2(config-line)# password C0nsole!Lab
SW1-Floor2(config-line)# login
SW1-Floor2(config-line)# exit
SW1-Floor2(config)# interface vlan 1
SW1-Floor2(config-if)# ip address 192.168.1.2 255.255.255.0
SW1-Floor2(config-if)# no shutdown
SW1-Floor2(config-if)# exit
SW1-Floor2(config)# ip default-gateway 192.168.1.1
SW1-Floor2(config)# end
SW1-Floor2# copy running-config startup-config
Cisco IOS: name the switch, protect privileged mode and the console, give it a management address, and save.
  • hostname changes the name in the prompt, so you always know which device you are on.
  • enable secret sets the password for the enable command, stored as a hash (a one-way scrambled form). The older enable password is stored in plain text or weak encryption, so use enable secret.
  • line console 0 with password and login asks for a password on the console port.
  • no ip domain-lookup stops the device trying to look up a mistyped command as a host name, which otherwise freezes the prompt for several seconds.
  • A Layer 2 switch gets its management IP address on a virtual interface, interface vlan 1. A router gets IP addresses on its physical interfaces, for example interface g0/1 then ip address 10.0.0.1 255.255.255.0.
  • no shutdown turns an interface on. Router interfaces are shut down by default; switch ports are on by default.

The command you will use most

output
R1# show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     192.168.1.1     YES manual up                    up
GigabitEthernet0/1     10.0.0.1        YES manual administratively down down
GigabitEthernet0/2     unassigned      YES unset  down                  down
Cisco IOS: one line per interface. "administratively down" means no shutdown is missing; "down down" usually means a cable or the other end.
Careful: Common mistakes: forgetting to save (a power cut brings the old config back), typing show commands in config mode without do, forgetting no shutdown on a router interface, and putting an IP address on a physical port of a Layer 2 switch instead of interface vlan 1. Never use the same simple password for console and enable secret on a real network.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

The Cisco IOS command line · 1/7

Cisco IOS CLI

Cisco devices are configured by typing commands in the IOS command line, first over a console cable, later over SSH.

Prefer a video by a teacher? Find free videos on “Cisco IOS CLI basics modes hostname enable secret Packet Tracer CCNA” on YouTube ↗

In real life: A night change at an ISP point of presence

A NOC engineer in Bengaluru must add a new customer interface on a router at 2 am. She connects by SSH, runs show running-config interface g0/3 to see the current state, makes the change in interface configuration mode, checks it with do show ip interface brief, and confirms the customer can ping. Only then does she run copy running-config startup-config. If something had gone wrong before saving, a reload would have brought back the old, working configuration.

Practice (0/4 done)

Task 1 · Question

The prompt shows R1(config-if)#. Which mode are you in?

Task 2 · Question

You configured a switch and it works. Which command makes sure the configuration survives a reboot?

Task 3 · Practice

Packet Tracer lab: add one 2960 switch and one PC, and connect the PC to the switch console port with a console cable. From the PC Terminal, configure the switch: hostname SW1, enable secret, a console password with login, no ip domain-lookup, then save. Reload the switch and check that everything is still there.

Task 4 · Code · Python

Network engineers often parse show command output with a script. Write up_interfaces(output) that takes the text of show ip interface brief and returns a list of interface names whose Status is "up" AND Protocol is "up". Skip the header line. Hint: "administratively down" has a space, so use the LAST two words of each line as status and protocol.

Quick quiz

Question 1

1.Which command takes you from Switch> to Switch#?

Question 2

2.Where is the running-config stored?

Question 3

3.You are in global configuration mode and want to check interface status without leaving. What do you type?

Question 4

4.show ip interface brief shows a router interface as "administratively down". What is missing?

Question 5

5.Why is enable secret preferred over enable password?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

Which command takes you from Switch> to Switch#?

Answer: enable

enable moves from user EXEC to privileged EXEC.

Where is the running-config stored?

Answer: RAM

The running-config is in RAM, so it is lost at reboot unless saved to NVRAM.

You are in global configuration mode and want to check interface status without leaving. What do you type?

Answer: do show ip interface brief

do runs an EXEC command from any configuration mode.

show ip interface brief shows a router interface as "administratively down". What is missing?

Answer: no shutdown on the interface

Administratively down means the interface is shut down in the configuration.

Why is enable secret preferred over enable password?

Answer: It is stored as a hash instead of plain text or weak encryption

enable secret stores a hashed password and takes priority over enable password.

A switch has 16 VTY lines. Only line vty 0 4 has transport input ssh. What is the risk?Related

Answer: Lines 5 to 15 may still accept Telnet

Unconfigured lines keep their own settings; secure all of them with line vty 0 15.

From Securing device access: secrets and SSH

Which command checks sshd configuration syntax?Related

Answer: sshd -t

sshd -t tests the config.

From SSH: keys, ssh-copy-id and hardening sshd

Why use gcloud config configurations?Related

Answer: To keep separate named sets of account, project and region, and switch between them

Configurations let you switch between clients or environments without retyping settings.

From The command line on all three clouds

Which command shows the VLANs allowed on a trunk?Related

Answer: show interfaces trunk

show interfaces trunk lists trunk ports, the native VLAN, and the VLANs allowed and active on each.

From Troubleshooting tools and common faults

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. This is the last topic of “Ethernet, MAC addresses and the Cisco CLI”. The module exam comes next.
  2. Module 2 exam: Ethernet, MAC addresses and the Cisco CLI · 13 questions · 20 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, IPv4 addressing. 57 topics left in the course before the final exam.

← Previous: ARP, the default gateway and ping