About Command Modes

Cisco Nexus 1000V CLI is divided into command modes which define the actions available to the user. Command modes are "nested" and are accessed in sequence. When you first log in, you are placed in CLI EXEC mode.

As you navigate from EXEC mode to global configuration mode, a larger set of commands are available to you. To transition to global configuration mode, enter the following command:

config t

The following table shows how command access builds from user EXEC to global configuration mode.

Command Mode

Prompt

Description

Exec

n1000v#

•Connect to remote devices.

•Temporarily change terminal line settings.

•Perform basic tests.

•List system information (show).

Global Configuration

n1000v(config)#

•Configure features, such as the following:

–port profile

–VLANs

–Interfaces

•Includes access to EXEC commands.

–Connect to remote devices.

–Temporarily change terminal line settings.

–Perform basic tests.

–List system information (show).

All commands in EXEC command mode are accessible from the global configuration command mode. For example, the show commands are available from any command mode.

EXEC Command Mode

When you first log in, you are placed into EXEC mode. The commands available in EXEC mode include the show commands that display device status and configuration information, the clear commands, and other commands that perform actions that you do not save in the device configuration.

Global Configuration Command Mode

Global configuration mode provides access to the most broad range of commands, including those used to make configuration changes that are saved by the device, and can be stored and applied when the device is rebooted.

Commands entered in global configuration mode update the running configuration file as soon as they are entered, but must also be saved into the startup configuration file by using the following command:

copy running-config startup-config

In global configuration mode, you can access a number of protocol-specific, platform-specific, and feature-specific configuration modes.

Accessing Interface Configuration Command Mode

To access and list the interface configuration commands, follow these steps:

Command

Purpose

Step 1

configure terminal

Example:

n1000v# configure terminal

n1000v(config)#

Enters global configuration mode.

Step 2

interfacetypenumber

Example:

n1000v(config)# interface ethernet 3/2

n1000v(config-if)#

Enters interface configuration mode for the interface you want to configure.

Exiting a Configuration Mode

To exit from any Configuration mode, use any of the following commands:

Command

Purpose

exit

Example:

svs(config-if)# exit

svs(config)#

Exits from the current configuration command mode and return to the previous configuration command mode.

end

Example:

svs(config)# end

svs#

Exits from the configuration command mode and returns to EXEC mode.

Ctrl-z

Example:

svs(config)# ^z

svs#

Exits the current configuration command mode and returns to EXEC mode.

Caution If you use Ctrl-Z at the end of a command line in which a valid command has been typed, the CLI adds the command to the running configuration file. We recommend that you exit a configuration mode using the
exit or
end command.

Running Configuration

The running configuration is the configuration that is currently running on the device. It includes configuration changes from commands entered since the last time the device was restarted. If the device is restarted, the running configuration is replaced with a copy of the startup configuration. Any changes that were made to the running configuration but were not copied to the startup configuration are discarded.

Startup Configuration

The startup configuration is the configuration that is saved and that will be used by the device when you restart it. When you make configuration changes to the device, they are automatically saved in the running configuration. If you want configuration changes saved permanently, you must copy them to the startup configuration so that they are preserved when the device is rebooted or restarted.

Copying the Running Configuration to the Startup Configuration

You can use this procedure to copy changes you have made to the running configuration into the startup configuration so that they are saved persistently through reboots and restarts.

Command

Purpose

Step 1

copy running-config startup-config

Example:

n1000v(config)# copy running-config startup-config

(Optional) Saves the running configuration persistently through reboots and restarts by copying it to the startup configuration.

Special Characters

Table 6-2 lists the characters that have special meaning in Cisco Nexus 1000V text strings and should be used only in regular expressions or other special contexts.

Keystroke Shortcuts

Moves the cursor one character to the left.When you enter a command that extends beyond a single line, you can press the Left Arrow or Ctrl-B keys repeatedly to scroll back toward the system prompt and verify the beginning of the command entry, or you can press the Ctrl-A key combination.

Ctrl-C

Cancels the command and returns to the command prompt.

Ctrl-D

Deletes the character at the cursor.

Ctrl-E

Moves the cursor to the end of the line.

Ctrl-F

Moves the cursor one character to the right.

Ctrl-G

Exits to the previous command mode without removing the command string.

Ctrl-K

Deletes all characters from the cursor to the end of the command line.

Ctrl-L

Redisplays the current command line.

Ctrl-R

Redisplays the current command line.

Ctrl-T

Transposes the character to the left of the cursor with the character located to the right of the cursor.

Ctrl-U

Deletes all characters from the cursor to the beginning of the command line.

Ctrl-W

Deletes the word to the left of the cursor.

Ctrl-X, H

List history.

When using this key combination, press and release the Ctrl and X keys together before pressing H.

Ctrl-Y

Recalls the most recent entry in the buffer (press keys simultaneously).

Ctrl-Z

Ends a configuration session, and returns you to EXEC mode.

When used at the end of a command line in which a valid command has been typed, the resulting configuration is first added to the running configuration file.

Displays the previous command in the command history.

Displays the next command in the command history.

Moves your cursor through the command history directionally to locate a command string.

?

Displays a list of available commands.

Tab

Completes the word for you after entering the first characters of the word, and then pressing the Tab key. All options that match are presented.

Used to complete:

•command names

•scheme names in the file system

•server names in the file system

•file names in the file system

Example

n1000v(config)# xm<Tab>

n1000v(config)# xml <Tab>

n1000v(config)# xml server

Example

n1000v(config)# c<Tab>

callhome class-map clock cts

cdp cli control-plane

n1000v(config)# cl<Tab>

class-map cli clock

n1000v(config)# cla<Tab>

n1000v(config)# class-map

Example

n1000v# cd bootflash:<Tab>

bootflash: bootflash://sup-1/
bootflash://sup-remote/

bootflash:/// bootflash://sup-2/
bootflash://sup-standby/

bootflash://module-5/ bootflash://sup-active/

bootflash://module-6/ bootflash://sup-local/

Example

n1000v# cd bootflash://mo<Tab>

bootflash://module-5/ bootflash://module-6/

n1000v# cd bootflash://module-

Abbreviating Commands

You can abbreviate commands and keywords by entering the first few characters of a command. The abbreviation must include sufficient characters to make it unique from other commands or keywords. If you are having trouble entering a command, check the system prompt and enter the question mark (?) for a list of available commands. You might be in the wrong command mode or using incorrect syntax.

Using the No Form of a Command

Almost every configuration command has a no form that can be used to disable a feature or function. For example, to remove a VLAN, use the no vlan command. To reenable it, use the plain vlan command form. The Cisco Nexus 1000V Command Reference, Release 4.2(1)SV1(4a) describes the no form of a command when available.

For example, if you use the boot command in global configuration mode, you can then use the no boot command undo the results:

n1000v(config)# boot system bootflash: svs1.bin

n1000v(config)# no boot system bootflash: svs1.bin

Using CLI Variables

The Cisco Nexus 1000V supports the definition and use of variables in CLI commands. You can use CLI variables as follows: ï

•Entered directly on the command line.

•Passed to the child script initiated using the run-script command. The variables defined in the parent shell are available for use in the child run-script command process (the "Running a Script" section).

The Cisco Nexus 1000V software provides one predefined system variable, the TIMESTAMP variable.

User-Defined CLI Session Variables

You can define CLI session variables to persist only for the duration of your CLI session using the cli var name command in EXEC mode. CLI session variables are useful for scripts that you execute periodically.

The following example shows how to create a user-defined CLI session variable.

svs# cli var name testinterface ethernet 3/2

You can reference a variable using the syntax $(variable).

The following example shows how to reference a user-defined CLI session variable.

n1000v# show interface $(testinterface)

Ethernet3/2 is up

Hardware is Ethernet, address is 0050.565a.2341 (bia 0050.565a.2341)

MTU 1500 bytes, BW -332641784 Kbit, DLY 10 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA

Port mode is trunk

full-duplex, 1000 Mb/s

Beacon is turned off

Auto-Negotiation is turned on

Input flow-control is off, output flow-control is off

Rx

222045 Input Packets 24263 Unicast Packets

89347 Multicast Packets 108435 Broadcast Packets

22529316 Bytes

Tx

33710 Output Packets 31393 Unicast Packets

1898 Multicast Packets 419 Broadcast Packets 461 Flood Packets

5221175 Bytes

91323 Input Packet Drops 0 Output Packet Drops

n1000v#

Use the show cli variables command to display user-defined CLI session variables.

The following example displays user-defined CLI session variables.

n1000v# show cli variables

VSH Variable List

-----------------

TIMESTAMP="2008-07-02-13.45.15"

testinterface="ethernet 3/1"

n1000v#

Use the cli no var name command to remove user-defined CLI session variables.

The following example removes a user-defined CLI session variable.

n1000v# cli no var name testinterface

User-Defined CLI Persistent Variables

You can define CLI variables that persist across CLI sessions and switch reloads using the cli var name command in configuration mode. These CLI persistent variables are defined in configuration mode and are saved in the running configuration file.

The following example shows how to create a user-defined CLI persistent variable.

n1000v# config t

n1000v(config)# cli var name mgmtport mgmt 0

n1000v(config)# exit

n1000v#

You can reference a variable using the syntax $(variable).

The following example shows how to reference a user-defined CLI persistent variable.

Working with Command Scripts

Running a Script

The run-script command executes the commands specified in a file. To use this command, be sure to create the file and specify commands in the required order.

Note You cannot create the script files at the switch prompt. You can create the script file on an external machine and copy it into the bootflash: directory. This section assumes that the script file resides in the bootflash: directory.

The syntax for this command is run-script filename.

This example displays the CLI commands specified in the file named testfile that resides in bootflash.

n1000v# show file bootflash:testfile
conf t
show interface mgmt 0

This file output is in response to the run-script command executing the contents in the testfile file: