- New and Changed Information
- Preface
- A Commands
- Advanced Services Modules Commands
- B Commands
- C Commands
- Caching Services Module Commands
- CLI Overview
- D Commands
- Debug Commands
- E Commands
- F Commands
- G Commands
- H Commands
- I Commands
- J Commands
- K Commands
- L Commands
- M Commands
- N Commands
- O Commands
- P Commands
- Q Commands
- R Commands
- S Commands
- Show Commands
- T Commands
- U Commands
- V Commands
- W Commands
- Z Commands
- About the Switch Prompt
- About the CLI Command Modes
- Understanding CLI Command Hierarchy
- Multiple Filter Commands
- Searching and Filtering CLI Output Examples
- Displaying Users
- Sending Messages to Users
- Using the ping Command
- Using traceroute
- Setting the Switch Shell Timeout
- Setting the Switch Terminal Timeout
- Setting the Switch Terminal Type
- Setting the Switch Terminal Length
- Setting the Switch Terminal Width
- Displaying Terminal Settings
- Setting the Current Directory
- Displaying the Current Directory
- Listing the Files in a Directory
- Creating a New Directory
- Deleting an Existing Directory
- Moving Files
- Copying Files
- Deleting Files
- Displaying File Contents
- Saving Command Output to a File
- Directing show Command Output to a File
- Compressing and Uncompressing Files
- Displaying the Last Line in a File
- Executing Commands Specified in a Script
- Setting the Delay Time
CLI Overview
This chapter prepares you to configure switches from the CLI (command-line interface) and it describes the CLI command modes.
This chapter includes the following sections:
- About the Switch Prompt
- About the CLI Command Modes
- Understanding CLI Command Hierarchy
- Navigating Through CLI Commands
- Searching and Filtering CLI Output
- Using CLI Variables
- Using Command Aliases
- About Flash Devices
- Formatting Flash Disks and File Systems
- Using the File System
- Role-Based CLI
- Using Valid Formats and Ranges
- Using Debug Commands
About the Switch Prompt
If you are connected to the console port when the switch boots up, you see the output shown in Example 1-1.
Note Refer to the Cisco MDS 9100 Series Hardware Installation Guide, the Cisco MDS 9200 Series Hardware Installation Guide, the Cisco MDS 9216 Hardware Installation Guide, or the Cisco MDS 9500 Series Hardware Installation Guide for installation and connection instructions.
After the switch is powered on successfully, you see the default switch prompt ( switch#
). You can perform embedded CLI operations, access command history, and use command parsing functions at this prompt. The switch obtains the command string upon detecting an Enter (CR) and accepts commands from a terminal.
Example 1-1 Displays the Output When a Switch Boots Up
About the CLI Command Modes
Switches in the Cisco MDS 9000 Family 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 which indicates the commands that are available to you.
|
|
|
|
---|---|---|---|
Enables you to temporarily change terminal settings, perform basic tests, and display system information. Note Changes made in this mode are generally not saved across system resets. |
|
||
Enables you to configure features that affect the system as a whole. Note Changes made in this mode are saved across system resets if you save your configuration. Refer to the Cisco NX-OS 9000 Family Fundementals Configuration Guide for further information. |
|
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 config terminal command to conf t.
Understanding CLI Command Hierarchy
The 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 config terminal command. Figure 1-1 illustrates a portion of the config terminal command hierarchy.
Figure 1-1 CLI Command Hierarchy Example
To execute a command, you enter the command by starting at the top level of the hierarchy. For example, to configure a Fibre Channel interface, use the config terminal command. Once you are in configuration mode, entres the interface command. When you are in the interface submode, you can query the available commands there.
The following example shows how to query the available commands in the interface submode:
EXEC Mode Options
When you start a session on the switch, you begin in EXEC mode. Based on the role or group to which you belong, you have access to limited commands or to all commands (see the “Role-Based CLI” section). From the 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 next two sections list the EXEC mode commands for the Cisco MDS 9000 Family, the Cisco Fabric Switch for HP c-Class BladeSystem, and the Cisco Fabric Switch for IBM BladeCenter. Not all EXEC mode commands that are supported on the Cisco MDS 9000 Family switches are available on the Cisco Fabric Switch for HP c-Class BladeSystem and the Cisco Fabric Switch for IBM BladeCenter.
EXEC Mode Commands for the Cisco MDS 9000 Family
EXEC Mode Commands for the Cisco Fabric Switch for HP c-Class BladeSystem and the Cisco Fabric Switch for IBM BladeCenter
Configuration Mode Options
Configuration mode allows you to make changes to the existing configuration. When you save the configuration, these commands are preserved 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. When you are in configuration mode, the switch expects configuration commands from the user.
The following example shows output from the config terminal command:
Not all configuration mode commands that are available on the Cisco MDS 9000 Family are available on the Cisco Fabric Switch for HP c-Class BladeSystem and the Cisco Fabric Switch for IBM BladeCenter.
The following two sections list the configuration mode commands for the Cisco MDS 9000 Family, the Cisco Fabric Switch for HP c-Class BladeSystem, and the Cisco Fabric Switch for IBM BladeCenter. Not all configuration mode commands that are supported on the Cisco MDS 9000 Family switches are available on the Cisco Fabric Switch for HP c-Class BladeSystem and the Cisco Fabric Switch for IBM BladeCenter.
Configuration Mode Commands for the Cisco MDS 9000 Family
Configuration Mode Commands for the Cisco Fabric Switch for HP c-Class BladeSystem and the Cisco Fabric Switch for IBM BladeCenter
Configuration mode, also known as terminal configuration mode, has several submodes. Each of these submodes places you deeper in the prompt hierarchy. When you type exit, the switch backs out one level and returns you to the previous level. When you type end, the switch backs out to the user EXEC level. You can also type Ctrl-Z in configuration mode as an alternative to typing end.
Note When in configuration mode, you can alternatively enter:
You can execute an EXEC mode command from a configuration mode or submode prompt. You can issue 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 entered command is executed at the EXEC level and the prompt resumes its current mode level.
switch(config)#
do terminal session-timeout 0
switch(config)#
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 TAB completes the current word while Alt- P and Alt-N completes a previously entered command. |
|
Table 1-3 displays the commonly used configuration submodes for the Cisco MDS 9000 Family switches.
Table 1-4 displays the commonly used configuration submodes for the Cisco Fabric Switch for HP c-Class BladeSystem and the Cisco Fabric Switch for IBM BladeCenter.
Note SPAN is only supported on external ports.
Navigating Through CLI Commands
To redisplay a command you previously entered, press the Up Arrow key. You can continue to press the Up Arrow key to see more previously entered commands. Similarly, you can press the Down Arrow, Right Arrow, Left Arrow, and Delete keys to navigate through the command history and to modify an existing command string.
Getting Help
In any command mode, you can get a list of available commands by entering a question mark (?).
To obtain a list of commands that begin with a particular character sequence, type in those characters followed immediately by the question mark (?). Do not include a space.
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.
Command Completion
In any command mode, you can begin a particular command sequence and immediately press the Tab key to complete the rest of the command.
switch (config)# role <Tab>
switch (config)# role name
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 presented:
Using the no and Default Forms of Commands
You can enter the no form of any command to perform the following actions:
If you issue 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 residing in it. You must first exit the zone submode and return to configuration mode.
Port Names and Port Mapping
The Cisco Fabric Switch for HP c-Class BladeSystem has a different port-naming convention from the Cisco MDS 9000 Family switch. It has eight external ports and they are labeled ext1 through ext8. It has 16 internal ports and they are labeled bay1 through bay16.
Table 1-5 shows the port mapping between the Cisco MDS 9000 Family and the Cisco Fabric Switch for HP c-Class BladeSystem.
The Cisco Fabric Switch for IBM BladeCenter has a different port naming convention from the Cisco MDS 9000 Family switch. There are six external ports and they are labeled ext0 and ext15 through ext19. There are 14 internal ports and they are labeled bay1 through bay14. Table 1-6 shows the port mapping between the Cisco MDS 9000 Family switches and the Cisco Fabric Switch for IBM BladeCenter switches.
|
|
|
---|---|---|
When you enter commands that require port names for the Cisco Fabric Switch for HP c-Class BladeSystem or the Cisco Fabric Switch for IBM BladeCenter, use the appropriate naming convention from either Table 1-5 or Table 1-6 . See Example 1-2 and Example 1-3 for typical commands that require port names.
Example 1-3 show interface Command
Entering CLI Commands
Viewing Switch Configurations
You can view the ASCII form of the configuration file when required. To view the current configuration tree from the EXEC prompt, enter the show running-config command. If the running configuration is different from the startup configuration, enter the show startup-config command to view the ASCII version of the current startup configuration that was used to boot the switch.
You can also obtain specific information on the entire switch configuration by entering the relevant show commands. Configurations are displayed based on specified feature, interface, module, or VSAN. Available show commands for each feature are briefly described in this section and listed at the end of each chapter.
Examples 1-4 to 1-10 display a few show command examples.
Example 1-4 Displays Details on the Specified Interface
Example 1-5 Displays the Software and Hardware Version
Example 1-6 Displays the Running Configuration
Example 1-7 Displays the Difference between the Running and Startup Configuration
Example 1-8 Displays the Configuration for a Specified Interface
Note The show running interface command is different from the show interface command.
Example 1-9 Displays the Configuration for All Interfaces in a 16-Port Module
Example 1-10 Displays the Configuration Per VSAN
Saving a Configuration
To save the configuration, enter the copy running-config startup-config command from the EXEC mode prompt to save the new configuration into nonvolatile storage. Once this command is issued, the running and the startup copies of the configuration are identical.
Clearing a Configuration
To clear a startup configuration, enter the write erase command from the EXEC mode prompt. After this command is entered, the switch’s startup configuration reverts to factory defaults. The running configuration is not affected. The write erase command erases the entire startup configuration with the exception of any configuration that affects the loader functionality.
The write erase boot command only erases the configuration that affects the loader functionality. The loader functionality configuration includes the boot variables and the mgmt0 IP configuration information (IP address, netmask and default gateway).
Searching and Filtering CLI Output
The Cisco MDS NX-OS CLI provides ways of searching through large amounts of command output and filtering output to exclude information that you do not need. These features are enabled for the show command, which generally displays large amounts of data.
Note The show command is always entered in EXEC mode.
When output continues beyond what is displayed on your screen, the Cisco MDS NX-OS CLI displays a --More-- prompt. Pressing Return displays the next line; pressing the Spacebar displays the next screen of output.
To search the show command output, use the following command in EXEC mode:
|
|
---|---|
Begins unfiltered output of the show command with the first line that contains the pattern. |
Note Cisco MDS NX-OS documentation generally uses the vertical bar to indicate a choice of syntax. However, to search the output of the show command, you need to enter the pipe character (the vertical bar). In this section the pipe appears in bold (|
) to indicate that you should enter this character.
To filter show command output, use one of the following commands in EXEC mode:
You can enter the Ctrl-Z key combination at any time to interrupt the output and return to EXEC mode. For example, you can enter the show running-config | begin hostname command to start the display of the running configuration file at the line containing the hostname setting, then use Ctrl-Z when you get to the end of the information you are interested in capturing. See the “Searching and Filtering CLI Output Examples” section.
Multiple Filter Commands
Cisco MDS SAN-OS Release 2.1(1a) supports using multiple filters in the same show command output. This means you can use a combination of the available filters to format the output of any show command.
Note The maximum number of commands allowed is four. For example, you can enter a maximum of three filter commands or two filter commands and a redirection.
Cisco MDS SAN-OS Release 2.1(1a) also supports both filters and redirection in the same command. Now you can apply the required filters to the output of any command, and save the output using the file redirection. See the next section, “Searching and Filtering CLI Output Examples” section.
Searching and Filtering CLI Output Examples
The following is partial sample output of the show running-config | begin EXEC command. It begins displaying unfiltered output with the first line that contains the pattern vsan
.
The following is partial sample output of the show tech-support EXEC command. It begins displaying unfiltered output with the first line that contains the string show interface brief
.
The following is partial sample output of the show running-config | exclude EXEC command. It excludes any output line that contains the pattern vsan
.
The following is partial sample output of the show interface EXEC command. It includes all output with the pattern vsan
.
The following is partial sample output of the show interface EXEC command. It includes all output with the pattern FX
plus the next and previous five lines of output.
The following output of the show running-config EXEC command. It displays the number lines, or count, of the output.
The following output of the show interface brief EXEC command. It displays the interfaces where the administration mode is FX
.
The following output of the show interface brief EXEC command uses multiple filter commands. It display the number of interfaces, or count, where the administration mode is FX
.
The following show interface brief EXEC command uses multiple filter commands to redirect the output where the administration mode is FX
to the file named test.txt
in the directory SavedData
.
Displaying Users
The show users command displays all users currently accessing the switch.
Sending Messages to Users
The send command sends a message to all active CLI users currently using the switch. This message is restricted to 80 alphanumeric characters with spaces.
This example sends a warning message to all active users about the switch being shut down.
Using the ping Command
The ping command verifies the connectivity of a remote host or server by sending echo messages.
The syntax for this command is ping <host or ip address>
To abnormally terminate a ping session, type the Ctrl-C escape sequence.
Using traceroute
The traceroute command prints the routes taken by a specified host or IP address.
The syntax for this command is traceroute <host or ip address>
Setting the Switch Shell Timeout
Use the exec-timeout command in configuration mode to configure the lifetime of all terminal sessions on that switch. When the time limit configured by this command is exceeded, the shell exits and closes that session. The syntax for this command form is exec-timeout minutes
The default is 30 minutes. You can configure different timeout values for a console or a virtual terminal line (VTY) session. You can set the exec-timeout value to 0 to disable this feature so that the session remains active until you exit the switch. This change is saved in the configuration file.
Specifies the current console shell timeout to be 60 minutes.
Specifies the current console shell timeout to be 60 minutes.
Displaying VTY Sessions
Use the show line command to display all configured VTY sessions:
Clearing VTY Sessions
Use the clear line command to close a specified VTY session:
Setting the Switch Terminal Timeout
Use the terminal session-timeout command in EXEC mode to configure the automatic logout time for the current terminal session on that switch. When the time limit configured by this command is exceeded, the switch closes that session and exits.
The syntax for this command form is terminal session-timeout minutes.
The default is 30 minutes. You can set the terminal session-timeout value to 0 to disable this feature so the terminal remains active until you choose to exit the switch. This change is not saved in the configuration file.
Specifies the terminal timeout to be 600 minutes for the current session.
Setting the Switch Terminal Type
Use the terminal terminal-type command in EXEC mode to specify the terminal type for a switch.
The syntax for this command is terminal terminal-type terminal-type.
Specifies the terminal type. The terminal-type string is restricted to 80 characters and must be a valid type (for example vt100 or xterm). If a Telnet or SSH session specifies an unknown terminal type, the switch uses the vt100 terminal by default.
Setting the Switch Terminal Length
To set the terminal screen length for the current session, use the terminal length command in EXEC mode. This command is specific to only the console port. Telnet and SSH sessions set the length automatically.
The syntax for this command is terminal length lines.
Sets the screen length for the current session to 20 lines for the current terminal session. The default is 24 lines.
Setting the Switch Terminal Width
To set the terminal screen width for the current session, use the terminal width command in EXEC mode. This command is specific to only the console port. Telnet and SSH sessions set the width automatically.
The syntax for this command is terminal width columns.
Sets the screen length for the current session to 86 columns for the current terminal session. The default is 80 columns.
Displaying Terminal Settings
The show terminal command displays the terminal settings for the current session:
Using CLI Variables
The NX-OS CLI parser supports 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.
- Passed as command line arguments to the run-script command.
CLI variables have the following characteristics:
- You cannot reference a variables 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, the TIMESTAMP variable.
User-Defined CLI Session Variables
You can define CLI variables that persist only for the duration of your CLI session using the cli var name command in EXEC mode. These CLI variables are useful for scripts that you execute periodically.
The following example shows how to create a user-defined CLI session variables.
You can reference a variable using the syntax $( variable).
The following example shows how to reference a user-defined CLI session variables.
Use the show cli var 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:
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 variables are configured in the configuration mode and are saved in the running configuration file.
The following example shows how to create a user-defined CLI persistent variables.
You can reference a variable using the syntax $( variable).
The following example shows how to reference a user-defined CLI persistent variables.
Use the show cli var command to display user-defined CLI persistent variable.
The following example displays user-defined CLI persistent variables.
Use the no cli var name command in configuration mode to remove user-defined CLI persistent variables.
The following example removes a user-defined CLI persistent variables.
System Defined Variables
Cisco MDS SAN-OS supports one predefined variable: TIMESTAMP. This variable refers to the time of execution of the command in the format YYYY-MM-DD-HH.MM.SS.
Note The TIMESTAMP variable name is case sensitive. All letters must be uppercase.
The following example uses $(TIMESTAMP) when periodically gathering statistics into files using the command scheduler:
The following example uses $(TIMESTAMP) when redirecting show command output to a file:
Using Command Aliases
Command alias support has the following characteristics:
- Command aliases are global for all user sessions.
- Command aliases are persist 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.
- 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:
About Flash Devices
Every switch in the Cisco MDS 9000 Family contains one internal bootflash (see Figure 1-2). The Cisco MDS 9500 Series switch additionally contains one external CompactFlash called slot0 (see Figure 1-2 and Figure 1-3).
Figure 1-2 Flash Devices in the Cisco MDS 9000 Supervisor Module
Figure 1-3 External CompactFlash in the Cisco MDS 9000 Supervisor Module
Internal bootflash:
All switches in the Cisco MDS 9000 Family have one internal bootflash: that resides in the supervisor or switching module.You have access to two directories within the internal bootflash: file system.
- The volatile: directory which provides temporary storage, and is also the default. Files in temporary storage (volatile:) are erased when the switch reboots.
- The bootflash (nonvolatile storage): directory which provides permanent storage. The files in bootflash are preserved through reboots and power outages.
External CompactFlash (Slot0)
Cisco MDS 9500 Series directors contain an additional external CompactFlash called slot0:
The external CompactFlash, an optional device for MDS 9500 Series directors, can be used for storing software images, logs, and core dumps.
Formatting Flash Disks and File Systems
By formatting a flash disk or a file system, you are essentially clearing out the contents of the disk or the file system and restoring it to its factory-shipped state (see the “About Flash Devices” section and “Using the File System” section for additional information).
Initializing bootflash:
When a switch is shipped, the init system command is already performed and you do not need to enter it again. Initializing the switch resets the entire internal disk and erases all data in the bootflash: partition. The internal disk is composed of several file systems with bootflash: being one of them. All files in bootflash: are erased and you must download the system and kickstart images again. After entering an init system command, you do not have to format the bootflash: again since bootflash: is automatically formatted.
Note The init system command also installs a new loader from the existing (running) kickstart image. You can access this command from the switch(boot)#
prompt.
If bootflash: is found corrupted during a boot sequence, you will see the following message:
Use the format bootflash: command to only format the bootflash: file system. You can enter the format bootflash: command from either the switch#
or the switch(boot)#
prompts.
If you enter the format bootflash: command, you must download the kickstart and system images again.
Formatting Slot0:
Be sure to format an external CompactFlash device before using it to save files or images.
You can verify if the external CompactFlash device is formatted by inserting it into slot0: and entering the dir slot0: command.
- If the external CompactFlash device is already formatted, you can see file system usage information (along with any existing files).
- If the external CompactFlash device is unformatted (corrupted), you will see the following message:
Device unavailable
In this case, you need to format the CompactFlash device using the format slot0: command.
Note The slot0: file system cannot be accessed from the standby the loader>
prompt or the switch(boot)#
prompt, if the disk is inserted after booting the switch.
Using the File System
The switch provides the following useful functions to help you manage software image files and configuration files:
- Setting the Current Directory
- Displaying the Current Directory
- Listing the Files in a Directory
- Creating a New Directory
- Deleting an Existing Directory
- Moving Files
- Copying Files
- Deleting Files
- Displaying File Contents
- Saving Command Output to a File
- Compressing and Uncompressing Files
- Displaying the Last Line in a File
- Executing Commands Specified in a Script
- Setting the Delay Time
Setting the Current Directory
The cd command changes the current directory level to a specified directory level. CLI defaults to the volatile: files system. This command expects a directory name input.
Tip Any file saved in the volatile: file system will be erased when the switch reboots.
The syntax for this command is cd directory name
This example changes the current directory to the mystorage directory that resides in the slot0 directory:
This example changes the current directory to the mystorage directory that is in the current directory.
Displaying the Current Directory
The pwd command displays the current directory location. This example changes the directory and displays the current directory.
Listing the Files in a Directory
The dir command displays the contents of the current directory or the specified directory. The syntax for this command is dir directory or file name.
This example shows how to list the files on the default volatile: file system:
Creating a New Directory
The mkdir command creates a directory at the current directory level or at a specified directory level.
The syntax for this command is mkdir directory name.
This example creates a directory called test in the slot0 directory:
This example creates a directory called test at the current directory level.
Deleting an Existing Directory
The rmdir command deletes an existing directory at the current directory level or at a specified directory level. The directory must be empty to be deleted.
The syntax for this command is rmdir directory name.
This example deletes the directory called test in the slot0 directory:
This example deletes the directory called test at the current directory level:
Moving Files
The move command removes a file from the source directory and places it in the destination directory. If a file with the same name already exists in the destination directory, that file is overwritten by the moved file.
This example moves the file called samplefile from the slot0 directory to the mystorage directory:
This example moves a file from the current directory level:
Copying Files
The copy command copies a file.
This example copies the file called samplefile from the external CompactFlash (slot0) directory to the mystorage directory:
This example copies a file from the current directory level:
Deleting Files
The delete command deletes a specified file or the specified directory and all its contents.
This example shows how to delete a file from the bootflash: directory (assuming you are already in the bootflash: directory):
This example shows how to delete a file from an external CompactFlash (slot0):
This example deletes the entire my-dir
directory and all its contents:
Displaying File Contents
The show file command displays the contents of a specified file in the file system.
The syntax for this command is show file file_name.
This example displays the contents of the test file that resides in the slot0 directory:
This example displays the contents of a file residing in the current directory:
Saving Command Output to a File
You can force all screen output to go to a file by appending > filename to any command. For example, enter show interface > samplefile at the EXEC mode switch prompt to save the interface configuration to samplefile —a file created at the same directory level. At the EXEC mode switch prompt, enter a dir command to view all files in this directory, including the recently saved samplefile.
Note Redirection is allowed only if the current directory is on the volatile:
(default) or slot0:
file systems. Redirection is not allowed if the current directory is on the bootflash:
file system. The current directory can be viewed using the pwd command and changed using the cd command.
Directing show Command Output to a File
You can direct show command output to a file, either on the volatile file system, on slot0 CompactFlash memory, or on a remote server.
The following example shows how to direct the show running-config output to a file on the volatile file system:
The following example shows how to direct the show running-config output to a file on slot0 CompactFlash memory:
The following example shows how to direct the show running-config output to a file on a TFTP server:
Compressing and Uncompressing Files
The gzip command compresses (zips) the specified file using LZ77 coding.
This example directs the output of the show tech-support command to a file (Samplefile) and then zips the file and displays the difference in the space used up in the volatile: directory:
The gunzip command uncompresses (unzips) LZ77 coded files.
This example unzips the file that was compressed in the previous example:
Displaying the Last Line in a File
The tail command displays the last lines (tail end) of a specified file.
The syntax for this command is tail file name [number of lines]
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 files at the switch prompt. You can create the script file on an external machine and copy it the bootflash: directory. This section assumes that the script file resides in the bootflash: directory.
The syntax for this command is run-script file_name.
This example displays the CLI commands specified in the test file that resides in the slot0 directory:
This file output is in response to the run-script command executing the contents in the test file file:
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, you can create a script called test-script:
When you execute the slot0:test-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.
Role-Based CLI
By default, two roles exist in all switches:
- Network operator—Has permission to view the configuration.
- Network administrator—Has permission to execute all commands and to set up to 64 permission levels based on user roles and groups.
When you execute a command, perform command completion, or obtain contex-sensitive help, the switch software allows the operation to progress if you have the correct permission as specified in the description of the command.
Using Valid Formats and Ranges
Note Do not enter ellipsis (...), vertical bar ( |), less or great ( < >), bracket ( [ ]), or braces ( { }) in command lines. These characters have special meaning in Cisco MDS SAN-OS text strings.
Some commands require a MAC address, IP address, or IDs that must be designated in a standard format or given a range. See Table 1-7 .
Using Debug Commands
All debug commands are entered in privileged EXEC mode, and most debug commands take no arguments. Use the show debugging command to display the state of each debugging option.
To list and see a brief description of all the debugging command options, enter the command debug ? at the command line in privileged EXEC mode. For example:
Not all debugging commands listed in the debug ? output are described in this document. Commands are included here based on their usefulness in assisting you to diagnose network problems. Commands not included are typically used internally by Cisco engineers during the development process and are not intended for use outside the Cisco environment.
To enable all system diagnostics, enter the debug all command at the command line in privileged EXEC mode. For example:
To turn off all diagnostic output, enter the no debug all command at the command line in privileged EXEC mode. For example:
Using the no debug all command is a convenient way to ensure that you have not accidentally left any debug commands turned on.
Generating debug Command Output
Enabling a debug command can result in output similar to the following example for the debug modem command:
The router continues to generate such output until you enter the corresponding no debug command (in this case, the no debug modem command).
If you enable a debug command and no output is displayed, consider the following possibilities:
- The router may not be properly configured to generate the type of traffic you want to monitor. Use the more system:running-config EXEC command to check its configuration.
- Even if the router is properly configured, it may not generate the type of traffic you want to monitor during the particular period that debugging is turned on. Depending on the protocol you are debugging, you can use commands such as the TCP/IP ping EXEC command to generate network traffic.
Redirecting debug and Error Message Output
By default, the network server sends the output from debug commands and system error messages to the console. If you use this default, monitor debug output using a virtual terminal connection, rather than the console port.
To redirect debug output, use the logging command options within configuration mode as described in the following sections.
Possible destinations include the console, virtual terminals, internal buffer, and UNIX hosts running a syslog server. The syslog format is compatible with 4.3 Berkeley Standard Distribution (BSD) UNIX and its derivatives.
Note Be aware that the debugging destination you use affects system overhead. Logging to the console produces very high overhead, whereas logging to a virtual terminal produces less overhead. Logging to a syslog server produces even less, and logging to an internal buffer produces the least overhead of any method.
To configure message logging, you need to be in configuration command mode. To enter this mode, use the configure terminal command at the EXEC prompt.
Enabling Message Logging
To enable message logging to all supported destinations other than the console, enter the following command:
The default condition is logging on.
To direct logging to the console only and disable logging output to other destinations, enter the following command:
Setting the Message Logging Levels
You can set the logging levels when logging messages to the following devices:
Table 1-8 lists and briefly describes the logging levels and corresponding keywords you can use to set the logging levels for these types of messages. The highest level of message is level 0, emergencies. The lowest level is level 7, debugging, which also displays the greatest amount of messages. For information about limiting these messages, see sections later in this chapter.
|
|
|
|
---|---|---|---|
Limiting the Types of Logging Messages Sent to the Console
To limit the types of messages that are logged to the console, use the logging console router configuration command. The full syntax of this command follows:
The logging console command limits the logging messages displayed on the console to messages up to and including the specified severity level, which is specified by the level argument. Keywords are listed in order from the most severe level to the least severe.
The no logging console command disables logging to the console.
The following example sets console logging of messages at the debugging level, which is the least severe level and which displays all logging messages:
Logging Messages to an Internal Buffer
The default logging device is the console; all messages are displayed on the console unless otherwise specified.
To log messages to an internal buffer, use the logging buffered router configuration command. The full syntax of this command follows:
The logging buffered command copies logging messages to an internal buffer instead of writing them to the console. The buffer is circular in nature, so newer messages overwrite older messages. To display the messages that are logged in the buffer, use the show logging privileged EXEC command. The first message displayed is the oldest message in the buffer.
The no logging buffered command cancels the use of the buffer and writes messages to the console (the default).
Limiting the Types of Logging Messages Sent to Another Monitor
To limit the level of messages logged to the terminal lines (monitors), use the logging monitor router configuration command. The full syntax of this command follows:
The logging monitor command limits the logging messages displayed on terminal lines other than the console line to messages with a level up to and including the specified level argument. To display logging messages on a terminal (virtual console), use the terminal monitor privileged EXEC command.
The no logging monitor command disables logging to terminal lines other than the console line.
The following example sets the level of messages displayed on monitors other than the console to notification :
Logging Messages to a UNIX Syslog Server
To log messages to a syslog server host, use the logging host global configuration command. The full syntax of this command follows:
logging host { ip-address | host-name } [ xml ]
no logging host { ip-address | host-name } [ xml ]
The logging host command identifies a syslog server host that is to receive logging messages. The ip-address argument is the IP address of the host. By entering this command more than once, you build a list of syslog servers that receive logging messages.
The no logging host command deletes the syslog server with the specified address from the list of syslogs.
Limiting Messages to a Syslog Server
To limit the number of messages sent to syslog servers, use the logging trap router configuration command. The full syntax of this command follows:
The logging trap command limits the logging messages sent to syslog servers to logging messages with a level up to and including the specified level argument.
To send logging messages to a syslog server, specify its host address with the logging host command.
The default trap level is informational.
The no logging trap command returns the trap level to the default.
The current software generates the following categories of syslog messages:
- Error messages at the emergencies level.
- Error messages at the alerts level.
- Error messages at the critical level.
- Error messages about software or hardware malfunctions, displayed at the errors level.
- Interface up/down transitions and system restart messages, displayed at the notification level.
- Reload requests and low-process stack messages, displayed at the informational level.
- Output from the debug commands, displayed at the debugging level.
The show logging privileged EXEC command displays the addresses and levels associated with the current logging setup. The command output also includes ancillary statistics.
Example of Setting Up a UNIX Syslog Daemon
To set up the syslog daemon on a 4.3 BSD UNIX system, include a line such as the following in the file /etc/syslog.conf :
The local7 keyword specifies the logging facility to be used.
The debugging keyword specifies the syslog level. See Table 1-8 for other keywords that can be listed.
The UNIX system sends messages at or above this level to the specified file, in this case, /usr/adm/logs/tiplog. The file must already exist, and the syslog daemon must have permission to write to it.
For the System V UNIX systems, the line should read as follows: