Working with Files
This chapter contains the following sections:
Information About
Files
The Cisco Nexus 1000V
file system provides a single interface to all the file systems that the Cisco
Nexus 1000V switch uses, including:
-
Flash memory file
systems
-
Network file
systems (TFTP and FTP)
-
Any other endpoint
for reading or writing data (such as the running configuration)
Navigating the File System
Specifying File Systems
The syntax for specifying a file system is <file system name>:[//server/]. The following table describes file system syntax.
File System Name
|
Server
|
Description
|
bootflash
|
sup-active
sup-local
sup-1
module-1
|
Internal memory located on the active supervisor used for storing system images, configuration files, and other miscellaneous files. Cisco Nexus 1000V CLI defaults to the bootflash: file system
|
sup-standby
sup-remote
sup-2
module-2
|
Internal memory located on the standby supervisor used for storing system images, configuration files, and other miscellaneous files.
|
volatile
|
—
|
Volatile random-access memory (VRAM) located on a supervisor module used for temporary or pending changes.
|
Identifying the Directory You are Working From
You can display the directory name of your current CLI location.
Before You Begin
Before beginning this procedure, you must be logged in to the CLI in any command mode.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
pwd
|
Displays the present working directory.
|
Changing Your Directory
You can change your location in the CLI, from one directory or file system to another.
Cisco Nexus 1000V CLI defaults to the bootflash: file system.
 Note |
Any file saved in the volatile: file system is erased when the switch reboots.
|
Before You Begin
Before beginning this procedure, you must be logged in to the CLI in any command mode.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# pwd
|
Displays the directory name of your current CLI location.
|
Step 2 | switch# cd directory name
- switch# cd mystorage
Changes your CLI location to the mystorage directory that resides within the current directory.
If the current directory is bootflash: mydir, this command changes the current directory to bootflash: mydir/mystorage.
| Changes your CLI location to the root directory on the bootflash: file system.
|
switch# pwd
volatile:
switch# cd bootflash:
switch# pwd
volatile:
switch# cd bootflash:mydir
switch# pwd
volatile:
switch# cd mystorage
Listing the Files in a File System
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
dir [directory | filename]
|
Displays the contents of a directory or file.
|
switch(config)# dir
77824 Jul 26 01:48:13 2013 accounting.log
4096 Jun 24 21:08:18 2013 core/
4096 Jun 24 21:08:18 2013 log/
16384 Jun 24 21:07:59 2013 lost+found/
875 Jun 28 04:19:00 2013 mts.log
1955033 Jun 24 21:08:11 2013 n1000v-dk9-dplug.5.2.1.SK1.1.0.345.gbin
31329792 Jun 24 21:08:11 2013 n1000v-dk9-kickstart.5.2.1.SK1.1.0.345.gbin
98044335 Jun 24 21:08:15 2013 n1000v-dk9.5.2.1.SK1.1.0.345.gbin
4096 Jun 24 21:08:43 2013 vdc_2/
4096 Jun 24 21:08:43 2013 vdc_3/
4096 Jun 24 21:08:43 2013 vdc_4/
8401501 Jun 24 21:08:17 2013 vsmcpa.3.0.0.112.bin
Usage for bootflash://
498884608 bytes used
5905084416 bytes free
6403969024 bytes total
switch(config)#
Identifying Available File Systems for Copying Files
Before You Begin
Before beginning this procedure, you must be logged in to the CLI in EXEC mode.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
copy ?
|
Displays the source file systems available to the copy command.
|
Step 2 | switch# copy filename ?
| Displays the destination file systems available to the copy command for a specific file.
|
switch# copy ?
bootflash: Select source filesystem
core: Select source filesystem
debug: Select source filesystem
ftp: Select source filesystem
licenses Backup license files
log: Select source filesystem
nvram: Select source filesystem
running-config Copy running configuration to destination
scp: Select source filesystem
sftp: Select source filesystem
startup-config Copy startup configuration to destination
system: Select source filesystem
tftp: Select source filesystem
volatile: Select source filesystem
Using Tab Completion
You can have the CLI complete a partial file name in a command.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
show file filesystem name: partial filename <Tab>
|
Completes the filename when you type a partial filename and then press Tab and if the characters you typed are unique to a single file.
If not, the CLI lists a selection of file names that match the characters that you typed.
You can then retype enough characters to make the file name unique; and CLI completes the filename for you.
|
Step 2 | switch# show file bootflash:nexus-1000v- <Tab>
| Completes the file name for you
|
switch# show file bootflash:nexus-1000v-
bootflash:nexus-n1000v-dk9-dplug.5.2.1.SK1.1.0.345.gbin
bootflash:nexus-1000v-mzg.5.2.1.SK1.1.0.345.gbin
bootflash:nexus-1000v-kickstart-mzg.5.2.1.SK1.1.0.345.gbin
n1000v# show file bootflash:c<Tab>
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDSq93BrlHcg3bX1jXDMY5c9+yZSST3VhuQBqogvCPDGeLecA+j
...
...
switch#
Copying and Backing Up Files
You can copy a file, such as a configuration file, to save it or reuse it at another location. If your internal file systems are corrupted, you could potentially lose your configuration. Save and back up your configuration files periodically. Also, before installing or migrating to a new software configuration, back up the existing configuration files.
 Note |
Use the dir command to ensure that enough space is available in the destination file system. If enough space is not available, use the delete command to remove unneeded files.
|
Before You Begin
Before beginning this procedure, you must be of the following:
You are logged in to the CLI through a Telnet, or SSH connection.
Your device has a route to the destination if you are copying to a remote location. Your device and the remote destination must be in the same subnetwork if you do not have a router or default gateway to route traffic between subnets.
Your device has connectivity to the destination. Use the ping command to be sure.
The source configuration file is in the correct directory on the remote server.
The permissions on the source file are set correctly. Permissions on the file should be set to world-read.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
copy [source filesystem:] filename [destination filesystem:] filename- switch# copy system:running-config system run.cfg
Saves a copy of the running configuration to a remote switch.
- switch# copy bootflash: system_image bootflash://sup-standby/system_image
Copies a file from bootflash in the active supervisor module to bootflash in the standby supervisor module.
- switch# copy system:running-config bootflash:config
Copies a running configuration to the bootflash: file system.
- switch# copy scp:[//[username@]server][/path]/filename
Copies a source or destination URL for a network server that supports Secure
Shell (SSH) and accepts copies of files using the secure copy
protocol (scp).
- switch# copy sftp:[//[username@]server][/path]/filename///
Copies a source or destination URL for an SSH FTP (SFTP) network server.
- switch# copy system:running-config bootflash:my-config
Places a back up copy of the running configuration on the bootflash: file system (ASCII file).
- switch# copy bootflash: filename bootflash:directory/filename
Copies the specified file from the root directory of the bootflash: file system to the specified directory.
- switch# copy filename directory/filename
Copies a file within the current file system.
- switch# copy tftp:[//server[:port]][/path]/filenamesystem:/filename
Copies the source file to the running configuration on the switch, and configures the switch as the file is parsed line by line.
|
Copies a file from the specified source location to the specified destination location.
|
switch# copy system:running-config tftp://10.10.1.1/home/configs/switch3-run.cfg
switch# copy bootflash:system_image bootflash://sup-2/system_image
switch# copy system:running-config bootflash:my-config
switch# copy scp://user@10.1.7.2/system-image bootflash:system-image
switch# copy sftp://172.16.10.100/myscript.txt volatile:myscript.txt
switch# copy system:running-config bootflash:my-config
switch# copy bootflash:samplefile bootflash:mystorage/samplefile
switch# copy samplefile mystorage/samplefile
switch# copy tftp://10.10.1.1/home/configs/switch3-run.cfg system:running-config
Creating a Directory
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# mkdir directory name
|
Creates a directory at the current directory level.
|
switch# mkdir test
switch# mkdir bootflash:test
Removing an Existing Directory
This command is valid only on Flash file systems.
Before You Begin
Before beginning this procedure, be sure of the following:
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
rmdir [filesystem:[//module/]]directory
|
Removes a directory.
The directory name is case sensitive.
|
switch# rmdir test
switch# rmdir bootflash:test
Moving Files
 Caution |
If a file with the same name already exists in the destination directory, that file is overwritten by the moved file.
|
The move will not complete if there is not enough space in the destination directory.
Before You Begin
Before beginning this procedure, you must be logged in to the CLI.
Procedure | Command or Action | Purpose |
---|
Step 1 |
switch# move {source path and filename} {destination path and filename}
|
Moves the file from one directory to another in the same file system (bootflash:).
|
switch# move bootflash:samplefile bootflash:mystorage/samplefile
switch# move samplefile mystorage/samplefile
Deleting Files or Directories
You can delete files or directories on a Flash Memory device.
 Caution |
When deleting, if you specify a directory name instead of a file name, the entire directory and its contents are deleted.
|
Before You BeginYou must understand the following information:
When you delete a file, the software erases the file.
If you attempt to delete the configuration file or image specified by the CONFIG_FILE or BOOTLDR environment variable, the system prompts you to confirm the deletion.
If you attempt to delete the last valid system image specified in the BOOT environment variable, the system prompts you to confirm the deletion.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
delete [bootflash: | debug: | log: | volatile:] filename or directory name
|
Deletes a specified file or directory.
|
switch# delete bootflash:dns_config.cfg
switch# delete dns_config.cfg
Compressing Files
Before You Begin
Before beginning this procedure, you must be logged in to the CLI.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# gzip [path] filename
| Compresses the specified file.
|
Step 2 | switch# dir
| Displays the contents of the specified directory, including the newly-compressed file. The compressed filename suffix becomes .gz indicating that it is a compressed gzip file. Shows the file size of the newly-compressed file.
|
switch# gzip csafile
switch# dir
77824 Aug 21 13:37:25 2013 accounting.log
4096 Jun 24 21:08:18 2013 core/
14278 Aug 21 13:36:54 2013 csafile.gz
4096 Jul 26 02:47:21 2013 log/
16384 Jun 24 21:07:59 2013 lost+found/
875 Jun 28 04:19:00 2013 mts.log
1955033 Jun 24 21:08:11 2013 n1000v-dk9-dplug.5.2.1.SK1.1.0.345.gbin
31329792 Jun 24 21:08:11 2013 n1000v-dk9-kickstart.5.2.1.SK1.1.0.345.gbi
n
98044335 Jun 24 21:08:15 2013 n1000v-dk9.5.2.1.SK1.1.0.345.gbin
4096 Jun 24 21:08:43 2013 vdc_2/
4096 Jun 24 21:08:43 2013 vdc_3/
4096 Jun 24 21:08:43 2013 vdc_4/
8401501 Jun 24 21:08:17 2013 vsmcpa.3.0.0.112.bin
Usage for bootflash://
499183616 bytes used
5904785408 bytes free
6403969024 bytes total
Uncompressing Files
You can uncompress (unzip) a specified file that is compressed using LZ77 coding.
Before You Begin
Before beginning this procedure, you must be logged in to the CLI.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
gunzip [path] filename
|
Uncompresses the specified file.
The filename is case sensitive
.
|
Step 2 | switch# dir
| Displays the contents of a directory, including the newly uncompressed file.
|
switch# gunzip bootflash:errorsfile.gz
switch# dir bootflash:
2687 Jul 01 18:17:20 2013 errorsfile
16384 Jun 30 05:17:51 2013 lost+found/
4096 Jun 30 05:18:29 2013 routing-sw/
49 Jul 01 17:09:18 2013 sample_test.txt
1322843 Jun 30 05:17:56 2013 nexus-1000v-dplug-mzg.5.2.1.SK1.1.0.345.gbin
21629952 Jun 30 05:18:02 2013 nexus-1000v-kickstart-mzg.5.2.1.SK1.1.0.345.gbin
39289400 Jun 30 05:18:14 2013 nexus-1000v-mzg.5.2.1.SK1.1.0.345.gbin
Usage for bootflash://sup-local
258408448 bytes used
2939531264 bytes free
3197939712 bytes total
DCOS-112-R5#
Directing Command Output to a File
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# show running-config > [path | filename]
- switch# show running-config > volatile:filename
Directs the output of the command, show running-config, to the specified filename on the volatile file system.
- switch# show running-config > bootflash:filename
Directs the output of the command, show running-config, to the specified file in bootflash.
- switch# show running-config > tftp:// ipaddress/filename
Directs the output of the command, show running-config, to the specified file on a TFTP server.
- switch# show interface > filename
Directs the output of the command, show interface, to the specified file at the same directory level, for example, in bootflash.
|
Directs the output of the command, show running-config, to a path and filename.
|
switch# show running-config > volatile:switch1-run.cfg
switch# show running-config > bootflash:switch2-run.cfg
switch# show running-config > tftp://10.10.1.1/home/configs/switch3-run.cfg
switch# show interface > samplefile
Verifying a Bootable Image
You can verify the integrity of an image before loading it. This command can be used for both the system and kickstart images.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# show version image [bootflash: | modflash: |volatile:]
| Validates the specified image.
bootflash:—specifies bootflash as the directory name.
volatile:—Specifies volatile as the directory name.
modflash:—Specifies modflash as the directory name.
|
switch# show version image bootflash:n1000v-dk9-dplug.5.2.1.SK1.1.0.345.gbin
MD5 Verification Passed
image name: n1000v-dk9-dplug.5.2.1.SK1.1.0.345.gbin
plugin: version 5.2(1)SK1(1.1) [build 5.2(1)SK1(1.0.345)] [gdb]
compiled: 6/17/2013 0:00:00 [06/17/2013 12:16:57]
switch#
Loading a File into the Running Configuration
You can load an image into the running configuration
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# copy source path and file system:running-config
|
Copies the source file to the running configuration on the switch, and configures the switch as the file is parsed line by line.
|
Step 2 | switch# copy running-config startup-config
| (Optional) Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.
|
switch# copy tftp://10.10.1.1/home/configs/switch3-run.cfg system:running-config
switch# copy running-config startup-config
Rolling Back to a Previous Configuration
You can recover your configuration from a previously saved version.
 Note |
Each time you use a copy running-config startup-config command, a binary file is created and the ASCII file is updated. A valid binary configuration file reduces the overall boot time significantly. A binary file cannot be uploaded, but its contents can be used to overwrite the existing startup configuration. The write erase command clears the binary file.
|
Procedure | Command or Action | Purpose |
---|
Step 1 | switch# copy bootflash: {filename} startup-config
| Copies the configuration file (ASCII file) that was previously saved in the bootflash: file system to the startup configuration file.
|
switch# copy bootflash:June13 startup-config
Displaying Files
Displaying File Contents
Before You Begin
Before beginning this procedure, you must be logged in to the CLI.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
show file [bootflash: | debug: | volatile:] filename
|
Displays the contents of the specified file.
|
switch# show file bootflash:sample_test.txt
config t
Int veth1/1
no shut
end
show int veth1/1
switch#
Displaying Directory Contents
You can display the contents of a directory or file system.
Before You Begin
Before beginning this procedure, you must be logged in to the CLI.
Procedure | Command or Action | Purpose |
---|
Step 1 |
switch# pwd
|
Displays the present working directory.
|
Step 2 |
switch# dir
| Displays the contents of the directory.
|
switch# pwd
bootflash:
switch# dir
Usage for volatile://
0 bytes used
20971520 bytes free
20971520 bytes total
switch#
Displaying File Checksums
You can display checksums for checking file integrity.
Procedure | Command or Action | Purpose |
---|
Step 1 |
switch# show file filename [cksum | md5sum]show file {bootflash: | volatile: | debug:} filename [cksum | md5sum]
|
Provides the checksum or MD5 checksum of the file for comparison with the original file.
Provides the Message-Digest Algorithm 5 (MD5) checksum of the file. MD5 is an electronic fingerprint for the file.
|
switch# show file bootflash:cisco_svs_certificate.pem cksum
266988670
switch# show file bootflash:cisco_svs_certificate.pem md5sum
d3013f73aea3fda329f7ea5851ae81ff
Displaying the Last Lines in a File
Before You Begin
Before beginning this procedure, you must be logged in to the CLI in EXEC mode.
Procedure | Command or Action | Purpose |
---|
Step 1 | switch#
tail {path}[filename] {Number of lines}
|
Displays the requested number of lines from the end of the specified file.
The range for the number of lines is from 0 to 80.
|
switch# tail mts.log 5
AT 60000 usecs after 6/24/2013 21:8:37: MTS node 4: state changed from 'offline' to 'supervisor'
AT 820000 usecs after 6/24/2013 21:8:41: MTS node 4: state changed from 'supervisor' to 'active alone'
AT 310000 usecs after 6/24/2013 21:29:57: MTS state 'offline': last_sync_msg opc=0, seq_no=0x0, next_seqno=0x0
AT 310000 usecs after 6/24/2013 21:29:57: MTS node 4: state changed from 'offline' to 'supervisor'
AT 740000 usecs after 6/24/2013 21:30:7: MTS node 4: state changed from 'supervisor' to 'active alone'
Feature History for File Management
Feature Name
|
Releases
|
Feature Information
|
File Management
|
Release 5.2(1)SK1(2.1)
|
This feature was introduced.
|