cp

cp old_name new_name

Description

Copies a file from the specified file system or relative to the current working directory to another file on the specified file system or relative to the current working directory.

Syntax Description

old_name Specifies the name of the file that you want to copy.
new_name Specifies the name of the newly copied configuration or policy file.

Default

N/A.

Usage Guidelines

Use this command to copy a file from the specified file system or relative to the current working directory to another file on the specified file system or relative to the current working directory. This command provides the functionality to replicate an existing file by creating a new entry in the file system, reading the content of the existing file and writing that content to the new one. If given a different name, the new file can be created in the same directory as the existing file.

When you copy a configuration or policy file, remember the following:
  • XML-formatted configuration files have a .cfg file extension. The switch only runs .cfg files.
  • ASCII-formatted configuration files have a .xsf file extension. See Software Upgrade and Boot Options for more information.
  • Policy files have a .pol file extension.
  • Core dump files have a .gz file extension. See Usage Guidelines.

When you copy a configuration or policy file from the system, make sure youspecify the appropriate file extension. For example, when you want to copy a policy file, specify the filename and .pol.

When you copy a file on the switch, the switch displays a message similar to the following:

 Copy config test.cfg to config test1.cfg on switch? (y/n) 

Enter y to copy the file. Enter n to cancel this process and not copy the file.

When you enter y, the switch copies the file with the new name and keeps a backup of the original file with the original name. After the switch copies the file, use the ls command to display a complete list of files. In this example, the switch displays the original file named test.cfg and the copied file named test_rev2.cfg.

The following is sample output from the ls command:

...
-rw-r--r--    1 root     root       100980 Sep 23 09:16 test.cfg
-rw-r--r--    1 root     root       100980 Oct 13 08:47 test_rev2.cfg
...

When you enter n, the switch displays a message similar to the following:

Copy cancelled. 

For the memorycard option, the source and/or destination is a compact flash card or USB 2.0 storage device. You must mount the compact flash card or USB storage device for this operation to succeed. The cp command copies a file from the switch to the compact flash card, the USB storage device, or a file already on one of those devices. If you copy a file from the switch to the removable storage device, and the new filename is identical to the source file, you do not need to re-enter the filename.

Case-sensitive Filenames

Filenames are case-sensitive. In this example, you have a configuration file named Test.cfg. If you attempt to copy the file with the incorrect case, for example test.cfg, the switch displays a message similar to the following:

Error: cp: /config/test.cfg: No such file or directory 

Since the switch is unable to locate test.cfg, the file is not copied.

Local Filename Character Restrictions

This section provides information about the characters supported by the switch for local filenames.

When specifying a local filename, the switch permits only the following characters:
  • Alphabetical letters, upper case and lower case (A-Z, a-z).
  • Numerals (0-9).
  • Period ( . ).
  • Dash ( - ).
  • Underscore ( _ ).

When naming a local file, remember the requirements listed above.

Internal Memory and Core Dump Files

Core dump files have a .gz file extension. The filename format is: core.process-name.pid.gz where process-name indicates the name of the process that failed and pid is the numerical identifier of that process. If you have a BlackDiamond 8800 series switch and save core dump files to the compact flash card, the filename also includes the affected MSM/MM: MSM-A or MSM-B.

By making a copy of a core dump file, you can easily compare new debug information with the old file if needed.

When you configure and enable the switch to send core dump (debug) information to the internal memory card, specify the internal-memory option and associated internal-memory name options to copy an existing core dump file.

If you have an external compact flash card or a USB 2.0 storage device installed, you can copy the core dump file to that location. When you send core dump information to a removable storage device, specify the memorycard option and associated memorycard name options to copy an existing core dump file.

For information about configuring and sending core dump information to the internal memory card, see the configure debug core-dumps and save debug tracefiles memorycard commands.

For more detailed information about core dump files, see Troubleshooting.

Modular Switches Only

This command also replicates the action from the primary MSM/MM to the backup MSM/MM. For example, when you copy a file on the primary MSM, the same file is copied to the backup MSM/MM.

Example

The following example makes a copy of a configuration file named test.cfg and gives the copied file a new name of test_rev2.cfg:

cp test.cfg test_rev2.cfg

The following example makes a copy of a configuration file named primary.cfg on the switch and stores the copy on the removable storage device with the same name, primary.cfg:

cp primary.cfg /usr/local/ext

The above command performs the same action as entering:

cp primary.cfg /usr/local/ext 
OR 
cp primary.cfg /usr/local/ext/primary.cfg

History

This command was first available in ExtremeXOS 11.0.

The memorycard option was added in ExtremeXOS 11.1.

The internal-memory option was added in ExtremeXOS 11.4.

Support for USB 2.0 storage devices was added in ExtremeXOS 12.5.3.

Pathname support was added in ExtremeXOS 15.5.1.

Platform Availability

This command is available on all platforms.