To assist in configuring devices, the CLI command-line interface is divided into different command modes. Each command mode has its own set of specific commands. Entering a question mark ? at the system prompt (console prompt) displays a list of commands available for that particular command mode.
From each mode a specific command is used to navigate from one command mode to another. The standard order to access these modes is as follows: User EXEC Mode, Privileged EXEC Mode, Global Configuration Mode, Interface Configuration Mode. The following figure illustrates the command mode access path.
When starting a session, the User EXEC Mode is the initial mode. Only a limited subset of commands are available in User EXEC Mode. This level is reserved for tasks that do not change the configuration. To enter the next level, the Privileged EXEC Mode, a password is required.
The Privileged EXEC Mode gives access to commands that are restricted on EXEC Mode and provides access to the device Configuration Mode.
The Global Configuration Mode manages the device configuration on a global level. For specific interface configurations, enter the next level, the Interface Configuration Mode.
The Interface Configuration Mode configures specific interfaces in the device.
User EXEC Mode
After logging on to the device, the user is automatically in User EXEC command mode unless the user is defined as a privileged user. In general, the User EXEC commands allow the user to perform basic tests, and list system information.
The user-level prompt consists of the device host name followed by the angle bracket (>)
.
console>
The default host name is Console unless it has been changed using the hostname command in the Global Configuration Mode.
Privileged EXEC Mode
Because many of the privileged commands set operating parameters, privileged access is password protected to prevent unauthorized use. The password is not displayed on the screen and is case sensitive.
Privileged users are entered directly into the Privileged EXEC Mode. To enter the Privileged EXEC Mode commands from the User EXEC Mode, perform the following steps:
At the prompt enter the enable command and press <Enter>. A password prompt is
displayed.
Enter the password and press <Enter>. The password is displayed as *. The privileged EXEC Mode prompt is displayed. The Privileged EXEC Mode prompt consists of the device host name followed by the pound sign #.
console#
To return from Privileged Mode to User EXEC Mode, use the disable command.
The following example illustrates how to access Privileged EXEC Mode and return to the User EXEC Mode:
console>enable
Enter Password: ******
console#
console#disable
console>
The exit command is used to move back from any mode to a previous level mode, except from Privileged EXEC to User EXEC Mode, for example, from Interface Configuration Mode to Global Configuration Mode, and from Global Configuration Mode to Privileged EXEC Mode.
Global configuration commands apply to features that affect the system as a whole, rather than just a specific interface. The Privileged EXEC Mode command configure is used to enter the Global Configuration Mode.
The Global Configuration Mode commands perform the following:
At the Privileged EXEC Mode prompt, enter the command configure and press
<Enter>. The Global Configuration Mode prompt is displayed. The Global
Configuration Mode prompt consists of the device host name followed by the word
(config) and pound sign #.
console(config)#
To return from Global Configuration Mode to Privileged EXEC Mode, use one of the following commands:
exit
end
Ctrl+Z
The following example illustrates how to access Global Configuration Mode and return to the Privileged EXEC Mode:
console#
console#configure
console(config)#exit
console#
Interface Configuration Mode and Specific Configuration Modes
Interface Configuration commands modify specific IP interface operations such as a bridge-group, description, and so on. The five Interface Configuration Modes are as follows:
VLANContains commands to create an entire VLAN. The Global Configuration Mode command vlan database is used to enter the VLAN Interface Configuration Mode.
Port ChannelContains commands to configure port-channels, for example, assigning ports to a VLAN or port-channel. The Global Configuration Mode command interface port-channel is used to enter the port-channel Interface Configuration Mode.
Line InterfaceContains commands to configure management connections such as line speed, timeout settings, and so on. The Global Configuration Mode command line is used to enter the line configuration command mode.
Management Access ListContains commands to define management access-lists for management. The Global Configuration Mode command management access-list is used to enter the Port Channel Interface Configuration Mode.
EthernetContains commands to manage port configuration. The Global Configuration Mode command interface ethernet enters the Interface Configuration Mode to configure an ethernet type interface
To access and list the VLAN Interface Configuration Mode commands, perform the following steps:
At the Global Configuration Mode prompt, enter the command vlan database
and press <Enter>. The VLAN Interface Configuration Mode prompt is displayed.
The VLAN Interface Configuration Mode prompt consists of the device host namefollowed by the word (config-switch) and the pound sign (#).
console(config-switch)#
Enter the ? command. The list of VLAN Interface Configuration Mode commands is
displayed.
To access and list the port-channel Interface Configuration Mode commands, perform the following:
At the Global Configuration Mode prompt enter the command interface port-
channel port channel-number and press <Enter>. The Interface Configuration
Mode prompt is displayed. The Interface Configuration Mode prompt consists of the
device host name followed by the word (config-if)and the pound sign (#).
console(config-if)#
Starting the CLI
The switch can be managed over a direct connection to the switch console port, or via a Telnet connection. The switch is managed by entering command keywords and parameters at the prompt. The switch command-line interface (CLI) is similar to entering commands on a UNIX system.
If access is via a Telnet connection, ensure the device has an IP address defined and that the workstation used to access the device is connected to the device prior to using CLI commands.
Console Connection
To launch a command line window, perform the following steps:
Start the device and wait until the startup procedure is complete.
The User Exec Mode opens, and the Console> prompt is displayed.
Configure the device and enter the necessary commands to complete the required
tasks.
When finished, type quit or exit to exit the session.
When a different user is required to log on to the system, enter the login command in the Privileged EXEC Mode. The current user is logged off and the new user is logged on.
Editing Features
Entering Commands
A CLI command is a series of keywords and arguments. Keywords identify a command, and arguments specify configuration parameters. For example, in the command show interfaces status ethernet1/e5, show, interfaces, and status are keywords, ethernet is an argument that specifies the interface type, and 1/e5 specifies the unit/port.
To enter commands that require parameters, enter the required parameters after the command keyword. For example, to set a password for the administrator, enter: Console(config)# username admin password smith
Commands are entered manually on the CLI. To see the available commands for each Mode or within an Interface Configuration context, the CLI provides commands for displaying available commands, command syntax requirements and in some instances parameters required to complete the command. The standard command requesting help is the ?.
There are two instances where the help information can be displayed:
Keyword lookupEnter the character ? in place of a command. A list of all commands and corresponding help messages are displayed.
Partial keyword lookupIf a command is incomplete and the character ? is entered in place of a parameter, the matched parameters for this command are displayed.
The CLI uses the following editing features:
Terminal Command Buffer
Command Completion
Keyboard Shortcuts
Terminal Command Buffer
When a command is entered in the CLI, it is recorded on an internally managed Command History buffer. Commands are stored in the buffer, which is maintained on a First In First Out (FIFO) basis. These commands can be recalled, reviewed, modified, and reissued. This buffer is not preserved across device resets.
The following table describes commands to access the buffer:
Keyword
Source or destination
Up arrow key, Ctrl+P
Recalls commands in the history buffer, beginning with the most recent command. Repeat the key sequence to recall successively older commands.
Down arrow key
Returns to more recent commands in the history buffer after recalling commands with the up arrow key. Repeating the key sequence will recall successively more recent commands.
By default, the history buffer system is enabled, but it can be disabled at any time. For the command syntax to enable or disable the history buffer, see history.
There is a standard default number of commands that are stored in the buffer. The standard number of 10 commands can be increased to 256. By configuring 0, the effect is the same as disabling the history buffer system. For the command syntax on configuring the command history buffer, see history size.
Many configuration commands use the prefix keyword no to cancel a command or reset the configuration to the default value. This guide describes the negation effect for all applicable commands.
Command Completion
When you type enough characters to identify a unique command, that command appears even if not complete. You can type the first few characters of a command to display all commands that begin with those characters. Press <Tab> repeatedly to move through the list to the correct command. For example, typing history s displays the command history size. Typing history displays the history and history size commands. To select history size, press <Tab> twice and then press <Enter>.
Incorrect or incomplete commands are automatically re-entered next to the cursor. If a parameter must be added, the parameter can be added to the basic command already displayed next to the cursor. The following example indicates that the command interface ethernet requires the parameter <port-num>.
(config)#interface ethernet
USAGE: interface ethernet <port-num>
port-num: The ethernet port
Mandatory parameter is omitted
(config)#interface ethernet
Keyboard Shortcuts
The CLI has a range of keyboard shortcuts to assist in editing the CLI commands. The following table describes the CLI shortcuts.
Keyboard Key
Description
Up arrow key
Recalls commands in the history buffer, beginning with the most recent command. Repeat the key sequence to recall successively older commands.
Down arrow key
Returns to more recent commands in the history buffer after recalling commands with the up arrow key. Repeating the key sequence will recall successively more recent commands.
Ctrl+A
Moves the cursor to the beginning of the command line.
Ctrl+E
Moves the cursor to the end of the command line.
Ctrl+z
Exits back to the next top level from all modes. For example, if in the Global Configuration Mode, exit back to the Privileged EXEC Mode.
Backspace key
Moves the cursor to the end of the command line.
CLI Command Conventions
The following table describes the command conventions for the CLI.
Convention
Description
[ ]
Indicates an optional entry.
{ }
Indicates a selection of compulsory parameters separated by the | character. One option must be selected. For example: flowcontrol {auto|on|off} means that for the flowcontrol command either auto, on, or off must be selected.
Italic font
Indicates a parameter.
<Enter>
Any individual key on the keyboard. For example click <Enter>.
Ctrl+F4
Any combination keys pressed simultaneously on the keyboard.
Screen Display
Indicates system messages and prompts appearing on the console.
#/g# or e#
Interface number corresponding to the following format: g for giga port or e for ethernet port.
all
When defining a range of ports or parameters, the default is all when no parameters are defined. For example, the command interface range port-channel has the option of either entering a range of channels, or selecting all. When the command is entered without a parameter, it automatically defaults to all.