Router & Switch Essential Commands Cheat Sheet
Modes & Navigation
text
enable # Enter privileged EXEC mode
disable # Return to user EXEC mode
configure terminal # Enter global configuration mode
exit # Exit current mode/configuration
end # Return to privileged EXEC mode
show running-config # View current configuration
copy running-config startup-config # Save configuration
reload # Reboot device
Basic Configuration
text
hostname [NAME] # Set device hostname
enable secret [PASSWORD] # Set encrypted enable password
enable password [PASSWORD] # Set plaintext enable password (less secure)
service password-encryption # Encrypt plaintext passwords
banner motd # [TEXT] # # Set message of the day banner
Interface Configuration
text
interface [type][slot/port] # Enter interface configuration mode
description [TEXT] # Add interface description
ip address [IP] [MASK] # Configure IP address (routers)
no shutdown # Enable interface
shutdown # Disable interface
duplex [auto/full/half] # Set duplex mode
speed [10/100/1000/auto] # Set speed (switches)
switchport mode access # Set as access port (switch)
switchport mode trunk # Set as trunk port (switch)
switchport access vlan [ID] # Assign VLAN to access port
IP Routing
text
ip route [NETWORK] [MASK] [NEXT_HOP] # Static route
ip route [Link] [Link] [NEXT_HOP] # Default route
router rip # Enable RIP routing
network [NETWORK] # Advertise network in RIP
router ospf [PROCESS_ID] # Enable OSPF routing
network [NETWORK] [WILDCARD] area [AREA_ID]
ip routing # Enable IP routing (layer 3 switches)
VLAN Configuration (Switches)
text
vlan [ID] # Create VLAN
name [VLAN_NAME] # Name VLAN
show vlan # Display VLAN information
show vlan brief # Brief VLAN status
show interfaces trunk # Display trunk interfaces
vtp mode [server/client/transparent] # Configure VTP mode
vtp domain [NAME] # Set VTP domain name
Security
text
line console 0 # Console line configuration
password [PASSWORD]
login
line vty 0 15 # Telnet/SSH lines
password [PASSWORD]
login
transport input ssh/telnet # Specify access protocol
ip domain-name [DOMAIN] # Set domain name for SSH keys
crypto key generate rsa # Generate RSA keys for SSH
username [NAME] secret [PASS] # Create local user
access-list [1-99] permit/deny [SOURCE] [WILDCARD] # Standard ACL
access-list [100-199] permit/deny [PROTOCOL] [SOURCE] [DEST] [PORT] # Extended
ACL
ip access-group [ACL#] in/out # Apply ACL to interface
DHCP
text
ip dhcp pool [NAME] # Create DHCP pool
network [NETWORK] [MASK] # Define network for DHCP
default-router [GATEWAY] # Set default gateway
dns-server [DNS_IP] # Set DNS server
lease [DAYS] [HOURS] [MINUTES] # Set lease time
ip dhcp excluded-address [START] [END] # Exclude addresses from DHCP
Show Commands
text
show interfaces # All interface status
show interface [interface] # Specific interface details
show ip interface brief # IP interface summary
show ip route # Routing table
show ip protocols # Routing protocols
show version # Device hardware/software info
show flash: # Flash memory contents
show clock # System time
show cdp neighbors # CDP neighbor information
show mac address-table # MAC address table (switches)
show port-security # Port security status
show arp # ARP table
show history # Command history
Troubleshooting
text
ping [IP/HOSTNAME] # Test connectivity
traceroute [IP/HOSTNAME] # Trace path to destination
show logging # View system logs
debug [OPTION] # Enable debugging
no debug all # Disable all debugging
terminal monitor # View debug output on terminal
show processes cpu # CPU utilization
show memory # Memory statistics
Password Recovery
1. Interrupt boot process (Ctrl+Break)
2. Change configuration register:
text
confreg 0x2142
reset
Copy startup-config to running-config
Reset passwords
Change configuration register back:
text
config-register 0x2102
copy running-config startup-config
reload
Useful Shortcuts
text
Ctrl+A # Move to beginning of line
Ctrl+E # Move to end of line
Ctrl+U # Erase entire line
Ctrl+W # Erase previous word
Tab # Auto-complete commands
? # Context-sensitive help
[COMMAND] ? # Show available options for command
Note: Commands may vary slightly between Cisco IOS versions and device models.
Always test in lab environment first.