Cisco Nexus 1000V System Management Configuration Guide, Release 4.2(1)SV2(1.1)
Working with Files
Downloads: This chapterpdf (PDF - 1.38MB) The complete bookPDF (PDF - 6.72MB) | The complete bookePub (ePub - 2.87MB) | The complete bookMobi (Mobi - 5.19MB) | Feedback

Working with Files

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

This section describes how to navigate the file system and includes the following topics:

  • Specifying File Systems
  • Identifying the Directory You are Working From
  • Changing Your Directory
  • Listing the Files in a File System
  • Identifying Available File Systems for Copying Files
  • Using Tab Completion

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 ActionPurpose
    Step 1switch# pwd 

    Displays the present working directory.

     

    switch# pwd
    bootflash:

    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 ActionPurpose
      Step 1switch# pwd  

      Displays the directory name of your current CLI location.

       
      Step 2switch# cd directory name
      • switch# cd bootflash:

        Changes your CLI location to the root directory on the bootflash: file system.

      • switch# cd bootflash:mydir

        Changes your CLI location to the mydir directory that resides in the bootflash: file system.

      • 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 ActionPurpose
        Step 1switch# dir [directory | filename] 

        Displays the contents of a directory or file.

         
        switch# dir lost+found/
              49241     Jul 01 09:30:00 2008  diagclient_log.2613
              12861     Jul 01 09:29:34 2008  diagmgr_log.2580
                 31     Jul 01 09:28:47 2008  dmesg
               1811     Jul 01 09:28:58 2008  example_test.2633
                 89     Jul 01 09:28:58 2008  libdiag.2633
              42136     Jul 01 16:34:34 2008  messages
                 65     Jul 01 09:29:00 2008  otm.log
                741     Jul 01 09:29:07 2008  sal.log
                 87     Jul 01 09:28:50 2008  startupdebug
        
        Usage for log://sup-local
           51408896 bytes used
          158306304 bytes free
          209715200 bytes total
        switch# 

        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 ActionPurpose
          Step 1switch# copy ? 

          Displays the source file systems available to the copy command.

           
          Step 2switch# 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 ActionPurpose
            Step 1switch# 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 2switch# show file bootflash:c <Tab> 

            Completes the file name for you

             
            n1000v# show file bootflash: nexus-1000v-
            bootflash:nexus-1000v-dplug-mzg.4.0.4.SV1.0.42.bin      
            bootflash:nexus-1000v-mzg.4.0.4.SV1.0.42.bin
            bootflash:nexus-1000v-kickstart-mzg.4.0.4.SV1.0.42.bin
            n1000v# show file bootflash:c<Tab>
            -----BEGIN RSA PRIVATE KEY-----
            MIICXgIBAAKBgQDSq93BrlHcg3bX1jXDMY5c9+yZSST3VhuQBqogvCPDGeLecA+j
            ...
            ...
            n1000v#

            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 ActionPurpose
              Step 1switch# 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]/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 ActionPurpose
                Step 1switch# mkdir directory name
                • mkdir {bootflash: | debug: | volatile:}

                  Specifies the directory name you choose:

                  • bootflash:
                  • debug:
                  • volatile:
                • switch# mkdir bootflash:directory name

                  Creates a directory that you name in the bootflash: directory.

                 

                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:

                • You are logged in to the CLI.
                • The directory you want to remove is empty.
                Procedure
                   Command or ActionPurpose
                  Step 1switch# rmdir [filesystem:[//module/]]directory
                  • switch# rmdir directory

                    Removes the specified directory at the current directory level.

                  • switch# rmdir {bootflash: | debug: | volatile:} directory

                    Removes a directory from the file system.

                   

                  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 ActionPurpose
                    Step 1 switch# move {source path and filename} {destination path and filename}
                    • switch# move filename path/filename

                      Moves the file from one directory to another in the current file system.

                     

                    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 Begin

                    You 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 ActionPurpose
                      Step 1switch# delete [bootflash: | debug: | log: | volatile:] filename or directory name
                      • switch# delete filename

                        Deletes the named file from the current working directory.

                      • switch# delete bootflash:directory name

                        Deletes the named directory and its contents.

                       

                      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 ActionPurpose
                        Step 1switch# show command > [path] filename  

                        Directs the show command output to a file.

                         
                        Step 2switch# dir 

                        Displays the contents of the current directory, including the new file created in the first step.

                         
                        Step 3switch# gzip [path] filename 

                        Compresses the specified file

                         
                        Step 4switch# dir 

                        Displays the contents of the specified directory, including the newly-compressed file. Shows the difference in the file size of the newly-compressed file.

                         
                        switch# show system internal l2fm event-history errors >errorsfile
                        switch# dir
                               2687     Jul 01 18:17:20 2008  errorsfile
                              16384     Jun 30 05:17:51 2008  lost+found/
                               4096     Jun 30 05:18:29 2008  routing-sw/
                                 49     Jul 01 17:09:18 2008  sample_test.txt
                            1322843     Jun 30 05:17:56 2008  nexus-1000v-dplug-mzg.4.0.4.SV1.0.42.bin
                           21629952     Jun 30 05:18:02 2008  nexus-1000v-kickstart-mzg.4.0.4.SV1.0.42.bin
                           39289400     Jun 30 05:18:14 2008  nexus-1000v-mzg.4.0.4.SV1.0.42.bin
                        
                        Usage for bootflash://
                          258408448 bytes used
                         2939531264 bytes free
                         3197939712 bytes total
                        switch# gzip bootflash:errorsfile
                        switch# dir
                               1681     Jun 30 05:21:08 2008  cisco_svs_certificate.pem
                                703     Jul 01 18:17:20 2008  errorsfile.gz
                              16384     Jun 30 05:17:51 2008  lost+found/
                               4096     Jun 30 05:18:29 2008  routing-sw/
                                 49     Jul 01 17:09:18 2008  sample_test.txt
                            1322843     Jun 30 05:17:56 2008  nexus-1000v-dplug-mzg.4.0.4.SV1.0.42.bin
                           21629952     Jun 30 05:18:02 2008  nexus-1000v-kickstart-mzg.4.0.4.SV1.0.42.bin
                           39289400     Jun 30 05:18:14 2008  nexus-1000v-mzg.4.0.0.S1.0.34.bin
                        
                        Usage for bootflash://
                          258408448 bytes used
                         2939531264 bytes free
                         3197939712 bytes total
                        switch# 

                        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 ActionPurpose
                          Step 1switch# gunzip [path] filename 

                          Uncompresses the specified file.

                          The filename is case sensitive .

                           
                          Step 2switch# 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 2008  errorsfile
                                16384     Jun 30 05:17:51 2008  lost+found/
                                 4096     Jun 30 05:18:29 2008  routing-sw/
                                   49     Jul 01 17:09:18 2008  sample_test.txt
                              1322843     Jun 30 05:17:56 2008  nexus-1000v-dplug-mzg.4.0.0.SV1.0.42.bin
                             21629952     Jun 30 05:18:02 2008  nexus-1000v-kickstart-mzg.4.0.4.SV1.0.42.bin
                             39289400     Jun 30 05:18:14 2008  nexus-1000v-mzg.4.0.0.SV1.0424.bin
                          
                          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 ActionPurpose
                            Step 1switch# 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 Configuration File before Loading

                            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 ActionPurpose
                              Step 1switch# 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 2switch# 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# copy tftp://10.10.1.1/home/configs/switch3-run.cfg system:running-config

                              switch# show version image bootflash:isan.bin
                                image name: nexus-1000v-mz.4.0.4.SV1.1.bin
                                bios:       version unavailable
                                system:     version 4.0(4)SV1(1)
                                compiled:   4/2/2009 23:00:00 [04/23/2009 09:55:29]

                              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 ActionPurpose
                                Step 1switch# copy running-config bootflash: {filename}  

                                Reverts to a snapshot copy of a previously saved running configuration (binary file).

                                 
                                Step 2switch# copy bootflash: {filename} startup-config 

                                Reverts to a configuration copy that was previously saved in the bootflash: file system (ASCII file).

                                 
                                switch# copy running-config bootflash:June03-Running

                                switch# copy bootflash:my-config startup-config

                                Displaying Files

                                This section describes how to display information about files and includes the following procedures:

                                • Displaying File Contents
                                • Displaying Directory Contents
                                • Displaying File Checksums
                                • Displaying the Last Lines in a File

                                Displaying File Contents

                                Before You Begin

                                Before beginning this procedure, you must be logged in to the CLI.

                                Procedure
                                   Command or ActionPurpose
                                  Step 1switch# 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 ActionPurpose
                                    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 ActionPurpose
                                      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 ActionPurpose
                                        Step 1switch# 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 bootflash:errorsfile 5
                                        
                                        20) Event:E_DEBUG, length:34, at 171590 usecs after Tue Jul  1 09:29:05 2008
                                            [102] main(326): stateless restart

                                        Feature History for File Management

                                        Feature Name

                                        Releases

                                        Feature Information

                                        File Management

                                        4.0(4)SV1(1)

                                        This feature was introduced.