- Index
- Preface
- Product Overview
-
- Configuring Ethernet Interfaces
- Configuring VLANs
- Configuring Private VLANs
- Configuring Rapid PVST+
- Configuring Multiple Spanning Tree
- Configuring STP Extensions
- Configuring Port Channels
- Configuring Access and Trunk Interfaces
- Configuring the MAC Address Table
- Configuring IGMP Snooping
- Configuring Traffic Storm Control
-
- Configuring Fibre Channel Interfaces
- Configuring Domain Parameters
- Configuring N-Port Virtualization
- Configuring VSAN Trunking
- Configuring SAN PortChannels
- Configuring and Managing VSANs
- Configuring and Managing Zones
- Distributing Device Alias Services
- Configuring Fibre Channel Routing Services and Protocols
- Managing FLOGI, Name Server, FDMI, and RSCN Databases
- Discovering SCSI Targets
- Advanced Features and Concepts
- Configuring FC-SP and DHCHAP
- Configuring Port Security
- Configuring Fabric Binding
- Configuring Fabric Configuration Servers
- Configuring Port Tracking
Using the Command-Line Interface
This chapter describes the command-line interface (CLI) and CLI command modes. It includes the following sections:
Accessing the Command Line Interface
You can connect to the switch using a terminal plugged into the console port. See Console Settings for information on how to set console port parameters.
You can also connect to the switch with Telnet or SSH. The switch supports up to eight simultaneous Telnet and SSH connections. To connect with Telnet or SSH, you need to know the hostname or IP address of the switch.
To make a Telnet connection to the switch, perform these steps:
|
|
|
---|---|---|
Makes a Telnet connection from your host to the switch that you want to access. |
||
Alternatively, to make an SSH connection to the switch, use the following command:
|
|
---|---|
Makes an SSH connection from your host to the switch that you want to access. |
Using the CLI
The section includes the following topics:
Using CLI Command Modes
Switches in the Cisco Nexus 5000 Series have two main command modes: user EXEC mode and configuration mode. The commands available to you depend on the mode you are in. To obtain a list of available commands in either mode, type a question mark (?) at the system prompt.
Table 1-1 lists and describes the two commonly used modes, how to enter the modes, and the resulting system prompts. The system prompt helps you identify which mode you are in and the commands that are available to you in that mode.
You can abbreviate commands and keywords by entering just enough characters to make the command unique from other commands. For example, you can abbreviate the configure terminal command to conf t.
Changing Command Modes
Configuration mode, also known as terminal configuration mode, has several submodes. Each of these submodes places you further down in the prompt hierarchy. When you type exit, the switch backs out of the current level and returns you to the previous level. When you type end, the switch backs out to the user EXEC level. You can also press Ctrl-Z in configuration mode as an alternative to typing end.
Listing the Commands Used with Each Command Mode
You can display the commands available in any command mode by typing a question mark (?) at the switch prompt.
CLI Command Hierarchy
CLI commands are organized hierarchically, with commands that perform similar functions grouped under the same level. For example, all commands that display information about the system, configuration, or hardware are grouped under the show command, and all commands that allow you to configure the switch are grouped under the configure terminal command.
To execute a command, you enter the command by starting at the top level of the hierarchy. For example, to configure an interface, use the config terminal command. Once you are in configuration mode, enter the interface command. When you are in the interface submode, you can query the available commands.
The following example shows how to query the available command in the interface submode:
EXEC Mode Commands
When you start a session on the switch, you begin in EXEC mode. From EXEC mode, you can enter configuration mode. Most of the EXEC commands are one-time commands, such as show commands, which display the current configuration status.
The following commands are available in EXEC mode:
switch#
?
Configuration Mode Commands
Configuration mode allows you to make changes to the existing configuration. When you save the configuration, these commands are saved across switch reboots. Once you are in configuration mode, you can enter interface configuration mode, zone configuration mode, and a variety of protocol-specific modes. Configuration mode is the starting point for all configuration commands.
The following commands are available in configuration mode:
Using Commands
You can configure the CLI to function in two ways: configure it interactively by entering commands at the CLI prompt or create an ASCII file containing switch configuration information (use the CLI to edit and activate the file).
Listing Commands and Syntax
In any command mode, you can obtain a list of available commands by entering a question mark (?).
To see a list of commands that begin with a particular character sequence, type those characters followed by a question mark (?). Do not include a space before the question mark.
To list keywords or arguments, enter a question mark in place of a keyword or argument. Include a space before the question mark. This form of help is called command syntax help because it reminds you which keywords or arguments are applicable based on the commands, keywords, and arguments you have already entered.
Tip 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.
Entering Command Sequences
In any command mode, you can begin a particular command sequence, then immediately press the Tab key to complete the rest of the command.
This form of help is called command completion because it completes a word for you. If several options are available for the typed letters, all options that match those letters are displayed.
Undoing or Reverting to Default Values or Conditions
You can enter the no form of any command to perform the following actions:
If you enter the zone member command, you can undo the results:
If you want to delete a zone that you created:
You cannot delete a zone facility called test while still in zone configuration submode. You must first exit the zone submode and return to configuration mode.
If you enter the zone merge-control restrict vsan command, you can undo the results:
Using Keyboard Shortcuts
You can execute an EXEC mode command from a configuration mode or submode prompt. You can enter this command from any submode within the configuration mode. When in configuration mode (or in any submode), enter the do command along with the required EXEC mode command. The command is executed at the EXEC level, and the prompt resumes its current mode level.
In this example, terminal session-timeout is an EXEC mode command. You are entering an EXEC mode command using the configuration mode do command.
The do command applies to all EXEC mode commands other than the end and exit commands. You can also use the help (?) and command completion (Tab) features for EXEC commands when entering a do command along with the EXEC command.
Table 1-2 lists some useful command keys that can be used in both EXEC and configuration modes.
|
|
---|---|
Note The difference between Tab completion and Alt-P or Alt-N is that pressing Tab completes the current word, while Alt-P and Alt-N completes a previously entered command. |
|
Table 1-3 describes the commonly used configuration submodes.
|
|
|
---|---|---|
Using CLI Variables
The Cisco Nexus 5000 Series CLI parser supports the definition and use of variables in CLI commands. CLI variables can be used 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 (see the “Executing Commands Specified in a Script” section).
- Passed as command line arguments to the run-script command (see the “Executing Commands Specified in a Script” section).
CLI variables have the following characteristics:
- You cannot reference a variable through another variable using nested references.
- You can define persistent variables that are available across switch reloads.
- You can reference only one predefined system variable, which is the TIMESTAMP variable.
User-Defined Persistent CLI 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:
You can reference a variable using the syntax $(variable). The following example shows how to reference a user-defined CLI session variable:
Use the show cli variables command to display user-defined CLI session variables. The following example displays user-defined CLI session variables:
Use the cli no var name command to remove user-defined CLI session variables. The following example removes a user-defined CLI session variable:
Using Command Aliases
Command alias support has the following characteristics:
- Command aliases are global for all user sessions.
- Command aliases are saved across reboots.
- Commands being aliased must be typed in full without abbreviation.
- Command alias translation always takes precedence over any keyword in any configuration mode or submode.
- Command alias support is only available on the supervisor module, not the switching modules.
- Command alias configuration takes effect for other user sessions immediately.
- You cannot override the default command alias alias, which aliases the show cli alias command.
- Nesting of command aliases is permitted to a maximum depth of 1. One command alias can refer to another command alias that must refer to a valid command, not to another command alias.
- A command alias always replaces the first command keyword on the command line.
- You can define command aliases for commands in any configuration submode or the EXEC mode.
Defining Command Aliases
You can define command aliases using the cli alias name command in configuration mode.
This following example shows how to define command aliases:
You can display the command aliases defined on the switch using the alias default command alias.
The following example shows how to display the command aliases defined on the switch:
Command Scripts
This section includes the following topics:
Executing Commands Specified in 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 file at the switch prompt. You can create the script file on an external machine and copy it to the bootflash: directory. This section assumes that the script file resides in the bootflash: directory.
The syntax for this command is run-scrip t filename.
This example displays the CLI commands specified in a test file that resides in the bootflash: directory.
This file output is in response to the run-script command executing the contents in the test file:
Using CLI Variables in Scripts
You can use CLI variables defined by the cli var command (see the “Using CLI Variables” section) or passed as arguments in the run-script command.
The following example shows how to use CLI session variables in a script file used by the run-script command:
The following example shows how you can pass CLI session variable as arguments to a child run-script command process:
Setting the Delay Time
The sleep command delays an action by a specified number of seconds.
The syntax for this command is sleep seconds.
You will see the switch prompt return after 30 seconds. This command is useful within scripts. For example, if you create a command script called test-script.
When you execute the test-script command script, the switch software executes the discover scsi-target remote command, and then waits for 10 seconds before executing the show scsi-target disk command.