Cisco IOS and IOS XE commands cheat sheet
Everyday Cisco CLI commands for switches and routers, grouped by task. The prompt shows the mode: > is user EXEC, # is privileged EXEC and (config)# is configuration mode. Changes go live at once but are lost on reboot until you save them.
- Covers
- Cisco IOS XE 17.x (most commands also work on IOS 15.x)
- Commands
- 60
- Last verified
Basics and modes
| Command | What it does |
|---|---|
enable | Enter privileged EXEC mode from user EXEC mode. Example Switch> enableThe prompt changes from > to #. Use disable to go back to user EXEC. |
configure terminal | Enter global configuration mode. Example Switch# configure terminalThe prompt becomes (config)#. Commands take effect in the running configuration as soon as you enter them. |
end | Return to privileged EXEC mode from any configuration mode. Ctrl-Z does the same. exit moves up only one level, for example from (config-if)# to (config)#. |
? | List the commands, keywords or arguments available at this point. Example show ?Type part of a word followed by ? (for example sh?) to list the commands that start with it. |
do <exec-command> | Run a show or other EXEC command without leaving configuration mode. Example do show ip interface briefdo cannot run configure terminal. |
<show-command> | include <regex> | Show only the output lines that match a pattern. Example show running-config | include hostnameUse | begin to start at the first match and | exclude to hide matching lines. Patterns are case sensitive. |
Device setup and secure access
| Command | What it does |
|---|---|
hostname <name> | Set the device name shown in the prompt. Example hostname SW1-OFFICEStart with a letter and use only letters, digits and hyphens, up to 63 characters. |
enable secret <password> | Set the password for privileged EXEC mode, stored as a one-way hash. Example enable secret Ch4nge-Me-2026Use enable secret rather than enable password. If both exist, enable secret wins. |
username <name> privilege 15 secret <password> | Create a local admin account with a hashed password. Example username netadmin privilege 15 secret Ch4nge-Me-2026Privilege 15 gives the user privileged EXEC access. Use secret, not password, so it is not stored reversibly. |
ip domain name <domain> | Set the default DNS domain name of the device. Example ip domain name example.comA hostname and domain name are needed before you can generate the RSA key for SSH. Older releases use ip domain-name. |
crypto key generate rsa general-keys modulus <bits> | Generate the RSA key pair that turns on the SSH server. Example crypto key generate rsa general-keys modulus 2048Use 2048 bits or more. If SSH commands are rejected, the key was not generated. |
ip ssh version 2 | Accept only SSH version 2 connections. Without this command the SSH server runs in compatibility mode and also accepts SSH version 1. Check with show ip ssh. |
line vty 0 15 | Enter configuration mode for the virtual terminal (SSH and Telnet) lines. The number of lines varies by platform (Catalyst 9000 switches have more). Apply SSH-only settings to every line. |
login local | Make the selected lines check logins against the local username database. Example Switch(config-line)# login localIf aaa new-model is configured, AAA method lists control login instead. |
transport input ssh | Allow only SSH, not Telnet, on the selected lines. Example Switch(config-line)# transport input ssh |
banner motd <c> <message> <c> | Set the message of the day shown to everyone who connects. Example banner motd # Authorized access only. Activity is logged. #<c> is any delimiter character that does not appear in the message. |
ntp server <ip-address> | Sync the device clock with an NTP server. Example ntp server 192.0.2.123Add prefer to the server you want used first when several are configured. |
logging host <ip-address> | Send syslog messages to a remote syslog server. Example logging host 192.0.2.50Repeat for more servers. logging trap <level> sets the lowest severity sent; the default is informational. |
Interfaces
| Command | What it does |
|---|---|
interface <interface> | Enter configuration mode for one interface. Example interface GigabitEthernet1/0/1Abbreviations such as gi1/0/1 also work. |
interface range <interface> - <last-port> | Configure several interfaces at once. Example interface range GigabitEthernet1/0/1 - 24Put a space before the hyphen. Separate several ranges with a comma. |
description <text> | Label an interface so its purpose shows in the configuration and show output. Example description Uplink to core switch |
ip address <ip-address> <subnet-mask> | Assign an IPv4 address to a routed interface or SVI. Example ip address 192.168.10.1 255.255.255.0On a switch, use it on an SVI (interface vlan) or on a physical port first turned into a routed port with no switchport. |
shutdown | Administratively disable an interface. The interface shows as administratively down until you enter no shutdown. |
no shutdown | Enable an interface that was shut down. Check the result with show ip interface brief. |
interface vlan <vlan-id> | Create or edit a switched virtual interface (SVI) for a VLAN. Example interface vlan 10Give it an IP address to manage the switch or to route between VLANs (with ip routing). |
VLANs and trunks
| Command | What it does |
|---|---|
vlan <vlan-id> | Create a VLAN and enter VLAN configuration mode. Example vlan 10Valid IDs are 1 to 4094. The prompt becomes (config-vlan)#. |
name <vlan-name> | Give the VLAN a name. Example name STAFFWithout a name the VLAN is called VLAN followed by its zero-padded ID, such as VLAN0010. |
switchport mode access | Make the port an access port that carries one untagged VLAN. |
switchport access vlan <vlan-id> | Put an access port in a VLAN. Example switchport access vlan 10If the VLAN does not exist yet, the switch creates it. |
switchport mode trunk | Make the port an 802.1Q trunk that carries several tagged VLANs. |
switchport trunk native vlan <vlan-id> | Set the VLAN used for untagged traffic on a trunk. Example switchport trunk native vlan 99The default is VLAN 1. Use the same native VLAN on both ends of the trunk or spanning-tree loops can result. |
switchport trunk allowed vlan <vlan-list> | Set the exact list of VLANs a trunk may carry. Example switchport trunk allowed vlan 10,20,99This replaces the existing list. Use ranges like 10-20 with no spaces. All VLANs are allowed by default. |
switchport trunk allowed vlan add <vlan-list> | Add VLANs to a trunk's allowed list without replacing it. Example switchport trunk allowed vlan add 30The same command takes remove, except, all and none. |
show vlan brief | List VLANs with their names, status and access ports. |
show interfaces trunk | Show trunk ports with their native VLAN and allowed and active VLANs. For one port's mode, native VLAN and allowed list, use show interfaces <interface> switchport. |
Routing
| Command | What it does |
|---|---|
ip routing | Turn on IPv4 routing on a Layer 3 switch. Catalyst switches start in Layer 2 mode with IP routing disabled. |
ip route <prefix> <mask> {<next-hop> | <interface>} [<distance>] | Add a static route. Example ip route 10.20.0.0 255.255.0.0 192.168.1.2Set a distance higher than your routing protocol's to make a floating backup route. Remove it with no ip route. |
ip route 0.0.0.0 0.0.0.0 <next-hop> | Add a default route (gateway of last resort). Example ip route 0.0.0.0 0.0.0.0 203.0.113.1 |
router ospf <process-id> | Start an OSPF process and enter router configuration mode. Example router ospf 1The process ID is local to the device and does not have to match neighbors. |
network <address> <wildcard-mask> area <area-id> | Run OSPF on interfaces whose addresses match the range and place them in an area. Example network 192.168.10.0 0.0.0.255 area 0Uses a wildcard (inverse) mask, not a subnet mask. Every area must connect to backbone area 0. |
show ip route | Show the routing table, including the gateway of last resort. Example show ip route 10.20.0.0Codes at the start of each line show the source, for example C connected, S static, O OSPF. |
show ip ospf neighbor | List OSPF neighbors and their adjacency state. Add detail for more. Neighbors that exchange routes reach FULL; DROTHER pairs on a LAN stay at 2WAY. |
Show and troubleshooting
| Command | What it does |
|---|---|
show version | Show the software version, uptime and hardware model. Example show version | include Version |
show running-config | Show the configuration currently in use. Add interface <interface> to see just one interface. |
show ip interface brief | List interfaces with their IP address and up or down status in one line each. Status administratively down means the interface is shut down. |
show interfaces status | List switch ports with description, status, VLAN, duplex, speed and type. Example show interfaces status err-disabled |
show interfaces <interface> | Show detailed status and counters for an interface, including errors. Example show interfaces GigabitEthernet1/0/1Reset the counters with clear counters <interface>. |
show cdp neighbors | List directly connected Cisco devices and the ports that link them. Example show cdp neighbors detaildetail adds IP address, software version and native VLAN. CDP must be enabled (cdp run). |
show mac address-table | Show the MAC addresses the switch has learned and the port and VLAN for each. Example show mac address-table interface GigabitEthernet1/0/5Filter with address <mac>, interface <interface>, vlan <vlan-id> or dynamic. |
ping <ip-address> | Send ICMP echo requests to test reachability. Example ping 192.0.2.10! means a reply and . means a timeout. Type ping alone in privileged EXEC mode for extended ping (source, count, size). |
traceroute <ip-address> | Show the hops packets take to reach a destination. Example traceroute 198.51.100.25* means a probe timed out. |
debug <feature> | Print live diagnostic messages for a feature. Example debug ip sshDebug output can load the CPU heavily on a busy device. On an SSH session, run terminal monitor to see it. |
undebug all | Turn off all debugging. Same as no debug all. Turning off console logging only hides output; it does not stop the debug. |
Saving and managing the configuration
| Command | What it does |
|---|---|
copy running-config startup-config | Save the running configuration so it survives a reload. Short form of copy system:running-config nvram:startup-config. |
write memory | Save the running configuration to NVRAM. Same result as copy running-config startup-config. |
show startup-config | Show the saved configuration the device will load at the next boot. |
reload | Restart the device. Warning: Drops all traffic through the device while it boots, and any unsaved changes in the running configuration are lost. Answer no at the save prompt only if you mean to discard them. |
reload in <minutes> | Schedule a restart after a number of minutes. Example reload in 10Warning: The device restarts and loses unsaved changes when the timer runs out. Useful as a safety net before risky remote changes; cancel it with reload cancel once you know you still have access. |
erase startup-config | Delete the saved startup configuration. Warning: The saved configuration is gone and cannot be restored on most platforms. After the next reload the device boots with no configuration. Back it up first. |
write erase | Delete the saved startup configuration (older form of erase nvram:). Warning: Same effect as erase startup-config: the saved configuration is lost and the device boots unconfigured after a reload. Cisco documents erase nvram: as the replacement. |
Official references
Last verified against these pages. Commands marked Warning restart, erase or remove something: run them only in a maintenance window and with a backup.
- Cisco Catalyst 9300 Command Reference, IOS XE 17.17.x: Using the Command-Line Interface cisco.com
- Cisco Catalyst 9300 System Management Configuration Guide, IOS XE 17.17.x: Administering the Device cisco.com
- Cisco Catalyst 9300 Security Configuration Guide, IOS XE 17.17.x: Controlling Switch Access with Passwords and Privilege Levels cisco.com
- Cisco: Configure SSH on Routers cisco.com
- Cisco Catalyst 9300 Interface and Hardware Configuration Guide, IOS XE 17.17.x: Configuring Interface Characteristics cisco.com
- Cisco Catalyst 9300 VLAN Configuration Guide, IOS XE 17.17.x: Configuring VLAN Trunks cisco.com
- Cisco Catalyst 9300 IP Routing Configuration Guide, IOS XE 17.17.x: Configuring OSPF cisco.com
- Cisco Catalyst 9300 System Management Configuration Guide, IOS XE 17.17.x: Managing Configuration Files cisco.com
Questions people ask
What is the difference between write memory and copy running-config startup-config?
Both save the running configuration so it is loaded at the next boot. copy running-config startup-config is the documented form and short for copy system:running-config nvram:startup-config. write memory is the older command that saves the running configuration to NVRAM. On a normal switch or router the result is the same.
What is the difference between enable secret and enable password?
Both protect privileged EXEC mode. enable secret stores a one-way hash (type 9 by default on current IOS XE), while enable password is kept in clear text unless service password-encryption applies weak, reversible type 7 encryption. If both are configured, enable secret takes precedence. Cisco recommends enable secret.
How do I enable SSH on a Cisco switch or router?
Set a hostname and ip domain name, create a local user with username <name> privilege 15 secret <password>, generate a key with crypto key generate rsa general-keys modulus 2048, and set ip ssh version 2. Then under line vty enter login local and transport input ssh. Check it with show ip ssh, and save with copy running-config startup-config.
How do I reset a Cisco switch to a blank configuration?
From privileged EXEC mode run erase startup-config (or write erase), then reload. When asked whether to save the modified configuration, answer no, otherwise the running configuration is written back. The device then boots with no configuration. Back up the configuration first.