01-Fundamentals Command Reference

HomeSupportRoutersH3C SR8800 Router SeriesReference GuidesCommand ReferencesH3C SR8800 Command Reference-Release3347-6W10301-Fundamentals Command Reference
04-File Management Commands
Title Size Download
04-File Management Commands 145.41 KB

 

 

NOTE:

Throughout this document, a filename can be entered as either of the following:

·       A fully qualified filename with the path included to indicate a file under a specific path. The filename can be 1 to 135 characters in length, excluding the ending character.

·       A short filename with the path excluded to indicate a file in the current working path. The filename can be 1 to 91 characters in length, excluding the ending character.

 

cd

Syntax

cd { directory | .. | / }

View

User view

Default level

3: Manage level

Parameters

directory: Name of the target directory, in the format of [drive:/]path, where drive represents the storage medium name. If no drive information is provided, the argument represents a folder or subfolder in the current directory.

..: Returns to an upper directory. If the current working directory is the root directory, or no upper directory exists, the current working directory does not change when the cd .. command is executed. This argument does not support command online help.

/: Returns to the root directory of the storage medium. The keyword does not support command line online help.

Description

Use the cd command to change the current working directory.

Examples

# Change the current working directory to flash:.

<Sysname> cd flash:

# Return to the upper directory (Remember to enter a space after the keyword cd).

<Sysname> cd ..

# Return to the root directory.

<Sysname> cd /

To view the path of the current working directory after you change the current directory by using the cd command, execute the pwd command.

# Enter the root directory of the flash on the standby MPU.

<Sysname> cd slot1#flash:/

copy

Syntax

copy fileurl-source fileurl-dest

View

User view

Default level

3: Manage level

Parameters

fileurl-source: Name of the source file.

fileurl-dest: Name of the target file or folder.

Description

Use the copy command to copy a file.

If you specify a target folder, the system copies the file to the specified folder and uses the name of the source file as the file name.

Examples

# Copy file testcfg.cfg in the current folder and save it as testbackup.cfg.

<Sysname> copy testcfg.cfg testbackup.cfg

Copy flash:/test.cfg to flash:/testbackup.cfg?[Y/N]:y

....

%Copy file flash:/test.cfg to flash:/testbackup.cfg...Done.

# Copy file 1.cfg in the test folder to the testbackup folder, and save it as 1backup.cfg.

<Sysname> copy flash:/test/1.cfg cfa0:/testbackup/1backup.cfg

Copy flash:/test/1.cfg to flash:/testbackup/1backup.cfg?[Y/N]:y

 

%Copy file flash:/test/1.cfg to flash:/testbackup/1backup.cfg...Done.

crypto-digest

Syntax

crypto-digest sha256 file file-url

View

User view

Default level

2: System level

Parameters

sha256: Specifies the SHA-256 algorithm.

file file-url: Name of a file.

Description

Use the crypto-digest command to compute the digest of a specified file.

The computed digest is used to verify the correctness and integrity of the file to prevent the file from being tampered with. For example, you can use the command to compute the digest of the software image file of a device, and compare the digest with that on the H3C web site to verify whether the file is valid.

Examples

# Use the SHA-256 algorithm to compute the digest of the file 1.cfg.

<Sysname> crypto-digest sha256 file 1.cfg

Computing digest...

SHA256 digest(1.cfg)=

7bcb92458222f91f9a09a807c4c4567efd4d5dc4e4abc06c2a741df7045433eb

delete

Syntax

delete [ /unreserved ] file-url

View

User view

Default level

3: Manage level

Parameters

/unreserved: Permanently deletes the specified file, and the deleted file can never be restored.

file-url: Name of the file to be deleted. Asterisks (*) are acceptable as wildcards. For example, to remove files with the extension of .txt in the current directory, you may use the delete *.txt command.

Description

Use the delete command to move a specified file from a storage medium to the recycle bin.

If you do not provide the /unreserved keyword, files deleted with this command are saved in the recycle bin, where you can restore the files with the undelete command or permanently delete them with the reset recycle-bin command.

The dir /all command displays the files deleted from the current directory and moved to the recycle bin. These files are enclosed in pairs of square brackets.

 

CAUTION

CAUTION:

If you delete two files in different directories but with the same filename, only the last one is retained in the recycle bin.

 

Examples

# Delete file tt.cfg in the root directory of the storage medium.

<Sysname> delete tt.cfg

Delete flash:/tt.cfg? [Y/N]:y

.

%Delete file flash:/tt.cfg...Done.

dir

Syntax

dir [ /all ] [ file-url | /all-filesystems ]

View

User view

Default level

3: Manage level

Parameters

/all: Displays all files and folders in the current directory, including hidden files, hidden folders, files moved from the current directory to the recycle bin. Files in the recycle bin are enclosed in square brackets [ ].

file-url: Displays the specified file. Asterisks (*) are acceptable as wildcards. For example, to display files with the .txt extension in the current directory, you may use the dir *.txt command.

/all-filesystems: Displays files and folders in the root directory of all storage media on the device.

Description

Use the dir command to display files or folders.

If no parameter is specified, the command displays all visible files and folders in the current directory.

Examples

# Display information about all files and folders in the current system.

<Sysname> dir /all

Directory of flash:/

 

   0   -rw-   6985954  Apr 26 2005 21:06:29   mainup.bin

   1   -rwh      1842  Apr 27 2005 04:37:17   private-data.txt

   2   -rw-      1518  Apr 26 2005 12:05:38   config.cfg

   3   -rw-      2045  May 04 2005 15:50:01   backcfg.cfg

   4   -rwh       428  Apr 27 2005 16:41:21   hostkey

   5   -rwh       572  Apr 27 2005 16:41:31   serverkey

   6   -rw-   2737556  Oct 12 2005 01:31:44     [a.app]

 

64770 KB total (5096 KB free)

# Display files and folders in the root directory of all storage media on the device.

<Sysname> dir /all-filesystems

Directory of flash:/

 

   0     -rw-  94967608  Nov 25 2010 15:24:50   mainup.bin

   1     -rw-      4000  Dec 20 2010 10:17:38   startup.cfg

   2     -rw-    327284  Oct 19 2010 15:27:26   mcul3722_v1.09.btw

   3     -rw-    101961  Nov 02 2010 14:08:10   hardcfg.txt

 

129794 KB total (36610 KB free)

 

Directory of cf0:/

 

   0     drw-         -  Nov 25 2009 15:34:32   logfile

   1     drw-         -  Jun 18 2000 20:03:02   diaglog

   2     -rw-  95151649  Dec 20 2010 10:16:42   mainup.bin

   3     -rw- 101782361  Nov 03 2010 18:24:32   backup.bin

   4     drw-         -  Apr 15 2007 01:37:18   123

   5     drw-         -  Feb 02 2007 00:20:36   info

 

252900 KB total (42916 KB free)

 

File system type of cf0: FAT16

Table 1 Output description

Field

Description

Directory of

The current working directory.

d

Indicates a directory; if this field does not exist, it indicates a file.

r

Indicates that the file or directory is readable.

w

Indicates that the file or directory is writable.

h

Indicates that the file or directory is hidden.

[ ]

Indicates that the file is in the recycle bin.

 

execute

Syntax

execute filename

View

System view

Default level

2: System level

Parameters

filename: Name of a batch file with a .bat extension. To change the suffix of the configuration file to .bat, use the rename commands.

Description

Use the execute command to execute the specified batch file.

Batch files are command line files. Executing a batch file is to execute a set of command lines in the file.

Do not include invisible characters in a batch file. If an invisible character is found during the execution, the batch process aborts and the commands that have been executed cannot be cancelled.

Not every command in a batch file is sure to be executed. For example, if a command is not correctly configured, the command fails and the system skips this command and goes to the next one.

The configuration generated after a batch file is executed is not automatically backed up to the standby MPU.

Each configuration command in a batch file must be a standard configuration command, meaning that the valid configuration information can be displayed with the display current-configuration command after this command is configured successfully; otherwise, this command may not be executed correctly.

Examples

# Execute batch file test.bat in the root directory.

<Sysname> system-view

[Sysname] execute test.bat

fdisk

Syntax

fdisk device [ partition-number ]

View

User view

Default level

3: Manage level

Parameters

device: Name of the storage medium to be partitioned. It cannot be the name of a partition.

partition-number: Number of partitions, which ranges from 1 to 4. Extended partitioning is not supported.

Description

Use the fdisk command to partition a storage medium.

If partition-number is specified, the storage medium is divided into the specified number of partitions; otherwise, partitioning is performed in an interactive way.

The router automatically formats each partition after partitioning is completed and all data on the storage medium is lost when this command is successfully executed.

Before removing a partitioned storage medium, unmount all the partitions. Otherwise, the file system on the storage medium may be damaged.

Before partitioning a USB disk, make sure that the disk is not write protected; otherwise, the partition operation fails, and you need to remount or re-plug the disk to restore normal access to the USB disk.

The command does not support repartitioning of a partition.

Examples

# Divide the CF card on the router evenly into three partitions in simple mode.

<Sysname> fdisk cf: 3

The capacity of cf: : 244M bytes

cf: will be divided into the following partition(s):

DeviceName  Capacity       

cf0:              81MB

cf1:              81MB

cf2:              82MB

All data on cf: will be lost, proceed with fdisk? [Y/N]:y

Now begin to fdisk cf:, please wait... done.

Reset (default) paths for files as needed, such as log file, ftp root directory, etc.

# Divide the CF card on the router into one partition in an interactive way.

<Sysname> fdisk cf:

The capacity of cf: : 244M bytes

Partition 1 (32MB~212MB, 244MB, CTRL+C to quit, Enter to use all space left):

// Press Enter or enter 244.

cf: will be divided into the following partition(s):

DeviceName  Capacity       

cf0:            256MB

All data on cf: will be lost, proceed with fdisk? [Y/N]:y

Now begin to fdisk cf:, please wait... done.

Reset (default) paths for files as needed, such as log file, ftp root directory, etc.

# Divide the CF card on the router into three partitions in an interactive way.

<Sysname> fdisk cf:

The capacity of cf: : 244M bytes

Partition 1 (32MB~212MB, 244MB, CTRL+C to quit, Enter to use all space left):

// Specify the size of the first partition as 100 MB (press Enter after entering 100).

Partition 2 (32MB~112MB, 144MB, CTRL+C to quit, Enter to use all space left):

// Specify the size of the second partition as 31 MB (press Enter after entering 31).

The partition size should be greater than or equal to 32MB.

Partition 2 (32MB~112MB, 144MB, CTRL+C to quit, Enter to use all space left):

// Specify the size of the second partition as 1000 MB (press Enter after entering 1000).

The partition size should be less than or equal to 144MB.

Partition 2 (32MB~112MB, 144MB, CTRL+C to quit, Enter to use all space left):

// Specify the size of the second partition as 120 MB (press Enter after entering 120).

The remaining space is less than 32MB. Please reenter the size of partition 2.

Partition 2 (32MB~112MB, 144MB, CTRL+C to quit, Enter to use all space left):

// Re-specify the size of the second partition as 40 MB (press Enter after entering 40).

Partition 3 (32MB~72MB, 104MB, CTRL+C to quit, Enter to use all space left):

// Assign the remaining space to the third partition (press Enter).

cf: will be divided into the following partition(s):

DeviceName  Capacity       

cf0:            100MB

cf1:              40MB

cf2:            104MB

All data on cf: will be lost, proceed with fdisk? [Y/N]:y

Now begin to fdisk cf:, please wait... done.

Reset (default) paths for files as needed, such as log file, ftp root directory, etc.

file prompt

Syntax

file prompt { alert | quiet }

View

System view

Default level

3: Manage level

Parameters

alert: Enables the system to warn you about operations that may bring undesirable results such as file corruption or data loss.

quiet: Disables the system from warning you about any operation.

Description

Use the file prompt command to set the file operation mode.

By default, the file operation mode is alert.

When the file operation mode is set to quiet, the system does not warn for any file operation. To avoid undesirable consequences resulting from misoperation, use the alert mode.

Examples

# Set the file operation mode to alert.

<Sysname> system-view

[Sysname] file prompt alert

fixdisk

Syntax

fixdisk device

View

User view

Default level

3: Manage level

Parameters

device: Storage medium name.

Description

Use the fixdisk command to restore the space of a storage medium when it becomes unavailable because of some abnormal operation.

You can execute the fixdisk command for the storage medium on the active MPU, but you cannot execute the command for the storage medium on the standby MPU.

Examples

# Restore the space of the flash.

<Sysname> fixdisk flash:

Fixdisk flash: may take some time to complete.

%Fixdisk flash: completed.

format

Syntax

format device [ FAT16 | FAT32 ]

View

User view

Default level

3: Manage level

Parameters

device: Name of a storage medium, for example, cf0 or cf1.

FAT16: Formats a storage medium by using the FAT16 format. FAT16 does not support Tab matching but needs to be entered completely if used, and is not applicable to a flash card.

FAT32: Formats a storage medium by using the FAT32 format. FAT32 does not support Tab matching but needs to be entered completely if used, and is not applicable to a flash card.

Description

Use the format command to format a storage medium.

 

CAUTION

CAUTION:

·       Formatting a storage medium results in loss of all the files on the storage medium and these files cannot be restored. In particular, if there is a startup configuration file on a storage medium, formatting the storage medium results in loss of the startup configuration file.

·       To format a storage medium, format each partition of the storage medium. For example, to format a CF card that has been partitioned, you need to format each partition, instead of formatting the CF card.

 

Examples

# Format the flash.

<Sysname> format flash:

All data on flash: will be lost, proceed with format? [Y/N]:y

 

%Format flash: completed.

# Format the third partition on the CF card.

<Sysname> format cf2:

All data on cf2: will be lost, proceed with format? [Y/N]:y

 

%Format cf2: completed.

mkdir

Syntax

mkdir directory

View

User view

Default level

3: Manage level

Parameters

directory: Name of a folder.

Description

Use the mkdir command to create a folder under a specified directory on the storage medium.

The name of the folder to be created must be unique in the specified directory. Otherwise, you will fail to create the folder in the directory.

To use this command to create a folder, the specified directory must exist. For instance, to create folder flash:/test/mytest, the test folder must exist. Otherwise, you will fail to create folder mytest.

Examples

# Create a folder named test in the current directory.

<Sysname> mkdir test

 

%Created dir flash:/test

# Create folder test/mytest in the current directory.

<Sysname> mkdir test/mytest

....

%Created dir flash:/test/mytest

# Create folder test on the standby MPU in slot 1).

<Sysname> mkdir slot1#flash:/test

....

%Created dir slot1#flash:/test.

 

more

Syntax

more file-url

View

User view

Default level

3: Manage level

Parameters

file-url: File name.

Description

Use the more command to display the contents of the specified file.

This command is valid only for text files.

Examples

# Display the contents of file test.txt.

Welcome to H3C.

# Display the contents of file testcfg.cfg.

<Sysname> more testcfg.cfg

 

#

 version 5.20, Beta 1201, Standard

#

 sysname Sysname

#

vlan 2

#

return

<Sysname>

# Display the contents of file testcfg.cfg on an standby MPU.

<Sysname> more slot1#flash:/testcfg.cfg

 

#

 version 5.20, Release 0000

#

 sysname Test

#

  ---- More ----

The More prompt indicates that there are more line that the screen can display. Pressing Enter displays the next line; pressing Space displays the next screen; pressing Ctrl+C or any other key exits the display.

mount

Syntax

mount device

View

User view

Default level

3: Manage level

Parameters

device: Name of a storage medium, for example cf0 or cf1.

Description

Use the mount command to mount a hot swappable storage medium, such as a CF card or USB disk (excluding the Flash card). This command is effective only when the router is in unmounted state.

By default, a storage medium is automatically mounted and in the mounted state after connected to the router, so you can use it without mounting it.

Do not remove the storage medium or swap a card when mounting or unmounting the router, or when you are processing files on the storage medium. Otherwise, the file system could be damaged.

When a storage medium is connected to a lower version system, the system may not be able to recognize the router automatically, and you need to use the mount command for the storage medium to function normally.

Before removing a mounted storage medium from the system, unmount it to avoid damaging the router.

Related commands: umount.

 

 

NOTE:

To mount a storage medium, mount each partition of the storage medium. For example, to mount a CF card that has been partitioned, you need to mount each partition, instead of mounting the CF card.

 

Examples

# Mount the third partition of the CF card.

<Sysname> mount cf2:

% Mount cf2: successfully.

%Apr 23 01:50:00:628 2008 Sysname VFS/5/LOG:

cf2: mounted into slot 0.

# Mount a CF card of the standby MPU in slot 1.

<Sysname> mount slot1#cf2:

% Mount slot1#cf2: successfully.

%Apr 23 01:50:00:628 2008 Sysname VFS/5/LOG:

cf2: mounted into slot 1

move

Syntax

move fileurl-source fileurl-dest

View

User view

Default level

3: Manage level

Parameters

fileurl-source: Name of the source file.

fileurl-dest: Name of the target file or folder.

Description

Use the move command to move a file.

If you specify a target folder, the system will move the source file to the specified folder, with the file name unchanged.

 

CAUTION

CAUTION:

The source file and target file must be on the same device. You cannot more files between devices of different types; otherwise, the move command cannot be executed.

 

Examples

# Move file flash:/test/sample.txt to flash:/, and save it as 1.txt.

<Sysname> move test/sample.txt 1.txt

Move flash:/test/sample.txt to flash:/1.txt?[Y/N]:y

...

% Moved file flash:/test/sample.txt to flash:/1.txt

# Move file b.cfg to the subfolder test2.

<Sysname> move b.cfg test2

Move flash:/b.cfg to flash:/test2/b.cfg?[Y/N]:y

.

%Moved file flash:/b.cfg to flash:/test2/b.cfg.

pwd

Syntax

pwd

View

User view

Default level

3: Manage level

Parameters

None

Description

Use the pwd command to display the current path.

Examples

# Display the current path.

<Sysname> pwd

flash:

rename

Syntax

rename fileurl-source fileurl-dest

View

User view

Default level

3: Manage level

Parameters

fileurl-source: Name of the source file or folder.

fileurl-dest: Name of the target file or folder.

Description

Use the rename command to rename a file or folder.

The target file name must be unique in the current path.

Examples

# Rename file sample.txt as sample.bat.

<Sysname> rename sample.txt sample.bat

Rename flash:/sample.txt to flash:/sample.bat? [Y/N]:y

 

% Renamed file flash:/sample.txt to flash:/sample.bat

reset recycle-bin

Syntax

reset recycle-bin [ /force ]

View

User view

Default level

3: Manage level

Parameters

/force: Deletes all files in the recycle bin.

Description

Use the reset recycle-bin command to permanently delete the files in the recycle bin of the current directory.

If a file is corrupted, you may not be able to delete the file using the reset recycle-bin command. Use the reset recycle-bin /force command to delete the corrupted file in the recycle bin.

The delete file-url command only moves a file to the recycle bin. To permanently delete the file in the recycle bin, use the reset recycle-bin command in the original directory of the file.

If the original path of the file to be deleted is not the current directory, use the cd command to enter the original directory of the file, and then execute the reset recycle-bin command.

Examples

# Execute the reset recycle-bin command in the current directory to delete file b.cfg from the recycle bin.

<Sysname> reset recycle-bin

Clear flash:/tt.cfg? [Y/N]:y

Clearing files from flash may take a long time. Please wait...

 

%Cleared file flash:/~/tt.cfg.

rmdir

Syntax

rmdir directory

View

User view

Default level

3: Manage level

Parameters

directory: Name of the folder.

Description

Use the rmdir command to remove a folder.

The folder must be an empty one. If not, you need to delete all files and subfolders under it with the delete command.

When you execute the rmdir command, the files that belonged to the folder are automatically deleted from the recycle bin.

Examples

# Remove folder mydir.

<Sysname> rmdir mydir

Rmdir flash:/mydir?[Y/N]:y

 

%Removed directory flash:/mydir.

umount

Syntax

umount device

View

User view

Default level

3: Manage level

Parameters

device: Name of a storage medium, for example cf0 or cf1.

Description

Use the umount command to unmount a hot swappable storage medium, such as a CF card or USB disk, excluding flash. This command is effective only when the storage medium is in mounted state.

By default, a storage medium is automatically mounted and in the mounted state. You need to unmount it before removing it from the router.

When mounting or unmounting a storage medium, or performing file operations on it, do not unplug or switchover the storage medium or the card where the storage medium resides. Otherwise, the file system could be damaged.

When a storage medium is connected to a lower version system, the system may not be able to recognize the router automatically, and you need to use the mount command for the storage medium to function normally.

Before removing a mounted storage medium from the system, you should first unmount it to avoid damaging the router.

Related commands: mount.

 

 

NOTE:

To unmount a storage medium, unmount each partition of the storage medium. For example, to unmount a CF card that has been partitioned, you need to unmount each partition, instead of unmounting the CF card.

 

Examples

# Unmount the third partition on the CF card.

<Sysname> umount cf2:

% Umount cf2: successfully.

%Apr 23 01:49:20:929 2008 Sysname VFS/5/LOG:

cf2: umounted from slot 4.

# Unmount a CF card of the standby MPU in slot 5.

<Sysname> umount slot5#cf2:

% Umount slot5#cf2: successfully.

%Apr 23 01:49:20:929 2008 Sysname VFS/5/LOG:

cf2: umounted from slot 5.

undelete

Syntax

undelete file-url

View

User view

Default level

3: Manage level

Parameters

file-url: Name of the file to be restored.

Description

Use the undelete command to restore a file from the recycle bin.

If another file with the same name exists in the same path, the system prompts you whether overwrite the original file.

Examples

# Restore deleted file sample.bak.

<Sysname> undelete sample.bak

Undelete flash:/sample.bak? [Y/N]:y

% Undeleted file flash:/sample.bak

 

  • Cloud & AI
  • InterConnect
  • Intelligent Computing
  • Security
  • SMB Products
  • Intelligent Terminal Products
  • Product Support Services
  • Technical Service Solutions
All Services
  • Resource Center
  • Policy
  • Online Help
All Support
  • Become a Partner
  • Partner Resources
  • Partner Business Management
All Partners
  • Profile
  • News & Events
  • Online Exhibition Center
  • Contact Us
All About Us
新华三官网