Basic Cisco Packet Tracer Commands and What They Do

Aisyah Aldina

Illustration of a keyboard for a guide on basic Cisco CLI commands

Hi everyone, now that you know your cable types, the next step is learning the basic Cisco commands in the CLI. Every configuration on a Cisco router or switch, from VLANs all the way to routing, is typed in the CLI, so the commands in this article will keep showing up in every Cisco article that follows.

Here I practice everything directly in Cisco Packet Tracer 8.2.1 using a Cisco 2960 switch. I connect to the switch from a PC over a console cable, exactly the way you would set up a brand new switch in the real world, and then I change the hostname, set passwords, create a banner, save the configuration, and test logging in again.

If you are still unsure about network cable types, read my guide on straight and crossover cables first.

Setting Up the Console Cable Topology

Place the switch, the PC, and the console cable

Topology of PC0 connected to Switch0 with a console cable in Packet Tracer

The only devices you need are 1 Cisco 2960-24TT switch and 1 PC (PC-PT). Connect them with the Console cable, which is the curved light blue cable icon in the Connections category.

PC0 RS 232  ->  Switch0 Console  (kabel console)

Click the Console cable, click PC0 and choose the RS 232 port, then click Switch0 and choose the Console port. A console cable does not carry network data. Its only job is to give you access to the device CLI. That is why a new switch with no IP address yet can still be configured through this cable.

Open the Terminal on the PC

Click PC0, open the Desktop tab, and choose Terminal. A port settings window appears with Bits Per Second 9600, Data Bits 8, Parity None, Stop Bits 1, and Flow Control None. These are the standard Cisco console settings, so just click OK. Once the switch finishes printing its boot text and shows Press RETURN to get started, press Enter until the Switch> prompt appears.

Modes in the Cisco CLI

Enter privileged mode and global configuration mode

Enable, configure terminal, and hostname commands in the Cisco switch CLI

The Cisco CLI has several modes, and each mode is marked by a different prompt.

enable
configure terminal
hostname SW-MAMANG

Switch> is user mode, where you can only view a little information. The enable command takes you to privileged mode, shown as Switch#, where you can run show commands and save the configuration. The configure terminal command takes you to global configuration mode, shown as Switch(config)#, which is where all the settings are made.

The hostname SW-MAMANG command renames the device right away, and you can see the prompt change to SW-MAMANG(config)#. A clear name helps a lot when you manage many switches at once.

Securing the Switch with Passwords and a Banner

Set the passwords, banner, and encryption

Configuring enable secret, console password, banner motd, and service password-encryption on a Cisco switch

Type the following commands one at a time in global configuration mode.

enable secret mamang123
line console 0
password cisco123
login
exit
banner motd #Hanya untuk admin Mamang Digital#
service password-encryption
no ip domain-lookup
end

Here is what each command does:

enable secret mamang123 sets the password for entering privileged mode, and this password is automatically stored as a hash.

line console 0 opens the console port settings, and the prompt changes to (config-line)#. Here, password cisco123 together with login makes anyone who connects through the console cable type a password.

banner motd shows a warning message before login. The hash signs at the start and end mark where the message begins and ends. My banner reads Hanya untuk admin Mamang Digital (Mamang Digital admins only).

service password-encryption encrypts passwords that are still stored as plain text, such as the console password.

no ip domain-lookup stops the switch from querying DNS every time you mistype a command, which usually leaves the CLI hanging for quite a while.

end returns you to privileged mode. The message %SYS-5-CONFIG_I: Configured from console by console is only a notice that the configuration was just changed.

Warning: The passwords in this tutorial are only examples. On real equipment, use long passwords and make the enable secret and console passwords different.

Checking the Configuration with Show Commands

View the running-config

Show running-config output with hostname, enable secret, banner, and encrypted password

The show running-config command displays the entire active configuration. To keep the output short, I filter it down to the important lines.

show running-config | include hostname|secret|password|banner

You can see the hostname is now SW-MAMANG, the enable secret is stored as a hash marked with the number 5, and the console password is stored with the number 7 because service password-encryption has encrypted it. The banner is in place too.

View the status of every port

Show ip interface brief output on a Cisco 2960 switch
show ip interface brief

This command lists every interface along with its IP address and status. All the FastEthernet ports are still down because nothing is plugged into them with a network cable yet. If the output is long and stops at –More–, press Space to continue or Q to stop.

Saving the Configuration

Save it to the startup-config

Saving the configuration with copy running-config startup-config and the OK result

So far all of these changes only live in the running-config, which sits in RAM. If the switch is powered off, everything is gone. Save it to the startup-config with the following command.

copy running-config startup-config

When it asks Destination filename [startup-config]?, just press Enter. The [OK] message means the configuration is saved permanently. The shorter write memory command does the same thing.

Testing the Login Again

Log out and log back in

Banner motd and password prompt when logging back in to a Cisco switch

Leave the session with exit, then press Enter.

exit

The banner Hanya untuk admin Mamang Digital (Mamang Digital admins only) appears right away, followed by User Access Verification and a Password prompt. Enter the console password cisco123, then type enable and enter the enable password mamang123. The password stays invisible while you type it, which is normal. The SW-MAMANG# prompt means both passwords work.

Tricks for Typing Commands Faster

Use command abbreviations

Abbreviated conf t and int fa0/1 commands used to add a port description

Cisco commands can be shortened as long as the abbreviation does not match another command. For example, conf t stands for configure terminal and int fa0/1 stands for interface FastEthernet0/1. In this example I add a description to port Fa0/1, and the text Ke PC Admin means “To Admin PC”.

conf t
int fa0/1
description Ke PC Admin
end

The (config-if)# prompt tells you that you are in interface configuration mode.

Checking the interface description with sh run include description in Cisco CLI

Check the result with a filtered sh run.

sh run | include description

Use the question mark for help

Question mark help co? listing the configure, connect, and copy commands

If you forget a command name, type its first letters followed by a question mark with no space. For example, co? lists every command that starts with co, which are configure, connect, and copy. You can also press Tab to complete a command you have partly typed.

Common Problems and How to Fix Them

Invalid input detected message

Invalid input detected message with a caret marker in the Cisco CLI

The ^ mark points to the part of the command that was not recognized. In this screenshot I tried sh run int fa0/1, which exists on real Cisco devices but is not supported in Packet Tracer. Other common causes are typos, or running a command in the wrong mode, for example typing hostname at the Switch# prompt. Make sure you are at the right prompt before you type a command.

Configuration lost after the switch restarts

The configuration was never saved. Always run copy running-config startup-config or write memory when you finish making changes.

Forgot the enable password

In Packet Tracer, the quickest fix is to delete the switch and place a new one. Real devices have a password recovery procedure through ROMmon mode, and the steps differ for each device series.

By now you can get into a Cisco switch CLI over a console cable, move between modes, set a hostname, passwords, and a banner, check the configuration, and save it. In the next article we will move on to switch configuration and IP addressing in Cisco Packet Tracer. If you have questions or run into a different error, just leave a comment below.

Leave a Comment