- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
04-File System Management Commands | 144.38 KB |
|
NOTE: Throughout this document, a filename can be entered as either of the following: · A fully qualified filename with a 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 no path 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. For more information about the drive and path arguments, see Fundamentals Configuration Guide. 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
# Enter the test folder after logging in to the switch.
<Sysname> cd test
# Return to the upper directory (Remember to enter a space after the keyword cd).
<Sysname> cd ..
# Return to the root directory.
<Sysname> cd /
# Enter the root directory of the flash on a standby main board (SMB) (the member ID and slot number of the member switch where the SMB resides are both 1) of the IRF fabric in IRF mode.
<Sysname> cd chassis1#slot1#flash:/
After changing the current working directory with the cd command, use the pwd command to view the current directory.
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 test.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 on the flash to the testbackup folder in the first partition of the CF card, and save it as 1backup.cfg.
<Sysname> copy flash:/test/1.cfg cfa0:/testbackup/1backup.cfg
Copy flash:/test/1.cfg to cfa0:/testbackup/1backup.cfg?[Y/N]:y
%Copy file flash:/test/1.cfg to cfa0:/testbackup/1backup.cfg...Done.
# Copy the configuration file of the active main board (AMB) of the IRF fabric to the root directory of an SMB (the member ID and the slot number of the member switch where the SMB resides are both 1) of the IRF fabric.
<Sysname> copy vrcfg.cfg chassis1#slot1#flash:/
Copy flash:/vrcfg.cfg to chassis1#slot1#flash:/vrcfg.cfg?[Y/N]:y
%Copy file flash:/vrcfg.cfg to chassis1#slot1#flash:/vrcfg.cfg...Done.
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 file-url command to temporarily delete a file. The deleted file is saved in the recycle bin. To restore it, use the undelete 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 [ ]. To remove the files from the recycle bin, use the reset recycle-bin command.
The delete /unreserved file-url command permanently deletes a file, and the deleted file cannot be restored. Use it with 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
# Remove file test.cfg from the root directory.
<Sysname> delete test.cfg
Delete flash:/test.cfg? [Y/N]:y
%Delete file flash:/test.cfg...Done.
# Remove file tt.cfg from the root directory of the storage medium on an SMB of the IRF fabric (the member ID and slot number of the member switch where the SMB resides are both 1).
· Method 1
<Sysname> delete chassis1#slot1#flash:/tt.cfg
Delete chassis1#slot2#flash:/tt.cfg?[Y/N]:y
%Delete file chassis1#slot1#flash:/tt.cfg...Done.
· Method 2
<Sysname> cd chassis1#slot1#flash:/
<Sysname> delete tt.cfg
Delete chassis1#slot1#flash:/tt.cfg?[Y/N]:y
%Delete file chassis1#slot1#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.
<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 [old.bin]
14605 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- 27496812 Aug 17 2007 13:08:18 mainup1.bin
1 -rw- 151 Dec 24 2010 15:49:18 system.xml
2 -rw- 39688708 Nov 29 2010 14:29:59 mainup2.bin
3 -rw- 39741380 Dec 07 2010 11:14:06 mainup3.bin
129794 KB total (25356 KB free)
Directory of cfa0:/
0 drw- - Jul 07 2007 07:07:18 logfile
1 drw- - Jul 07 2007 07:07:18 diaglog
2 -rw- 679 Jul 07 2007 07:54:18 aa.cfg
3 -rw- 31873064 Nov 29 2010 09:57:18 mainup1.bin
4 -rw- 5442 Dec 24 2010 15:49:20 config.cfg
5 -rw- 39741380 Dec 07 2010 11:09:10 mainup2.bin
6 -rw- 39788204 Dec 24 2010 13:41:40 mainup3.bin
7 -rw- 37650052 Nov 26 2010 14:25:18 mainup4.bin
8 drw- - Sep 06 2007 11:10:42 info
252900 KB total (38548 KB free)
File system type of cfa0: FAT16
Table 1 Output description
Field |
Description |
Directory of |
Current working directory. |
d |
Indicates a directory; if this field does not exist, it indicates a file. |
r |
The file or directory is readable. |
w |
The file or directory is writable. |
h |
The file or directory is hidden. |
[ ] |
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. You can use the rename command to change the suffix of the configuration file to .bat to use it as a batch file.
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.
You should not include invisible characters in a batch file. If an invisible character is found during the execution, the batch process will abort 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 certain command is not correctly configured, the command fails and the system goes to the next one.
The configuration generated after a batch file is executed is not automatically backed up to the SMB.
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; otherwise, this command may not be executed.
Examples
# Execute the 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.
|
NOTE: At present, only the CF card and USB disk can be partitioned. |
The switch automatically formats each partition after partitioning is completed and all data on the storage medium is lost after 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 switch into three partitions in simple mode.
<Sysname> fdisk cfa: 3
The capacity of cfa: : 244M bytes
cfa0: will be divided into the following partition(s):
DeviceName Capacity
cfa0: 81MB
cfa1: 81MB
cfa2: 81MB
All data on cfa: will be lost, proceed with fdisk? [Y/N]:y
% Now begin to fdisk cfa:, please wait... done.
Reset (default) paths for files as needed, such as log file, ftp root directory, etc.
# Divide the CF card on the switch into one partition in an interactive way.
<Sysname> fdisk cfa:
The capacity of cfa: : 244M bytes
Partition 1 (32MB~212MB, 244MB, CTRL+C to quit, Enter to use all space left):
// Press Enter or enter 244.
cfa: will be divided into the following partition(s):
DeviceName Capacity
cfa0: 244MB
All data on cfa: will be lost, proceed with fdisk? [Y/N]:y
% Now begin to fdisk cfa:, please wait... done.
Reset (default) paths for files as needed, such as log file, ftp root directory, etc.
# Divide the CF card on the switch into three partitions in an interactive way.
<Sysname> fdisk cfa:
The capacity of cfa: : 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 56).
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).
cfa: will be divided into the following partition(s):
DeviceName Capacity
cfa0: 100MB
cfa1: 40MB
cfa2: 104MB
All data on cfa: will be lost, proceed with fdisk? [Y/N]:y
Now begin to fdisk cfa:, 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 a prompt mode for file operations.
By default, the prompt mode is alert.
When the prompt mode is set to quiet, the system does not warn for any file operation. To avoid undesirable consequences resulting from misoperations, you are recommended to use the alert mode.
Examples
# Set the file operation prompt 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.
Examples
# Restore the space of the flash.
<Sysname> fixdisk flash:
format
Syntax
format device [ FAT16 | FAT32 ]
View
User view
Default level
3: Manage level
Parameters
device: Name of a partition (for example cf0 or cf1) of a storage medium that has been partitioned.
FAT16: Formats a storage medium 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 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: · 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 that has been partitioned, 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. · When you format a partitioned storage medium that has a capacity smaller than 32.5 M, you can only use the FAT16 format to format the storage medium. |
Examples
# Format the flash.
<Sysname> format flash:
All data on flash: will be lost, proceed with format? [Y/N]:y
./
%Format flash: 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.
<Sysname> mkdir test
....
%Created dir flash:/test
# Create folder test/subtest.
<Sysname> mkdir test/subtest
....
%Created dir flash:/test/subtest
# Create folder test on an SMB (the member ID and slot number of the member switch where the SMB resides are 2 and 1 respectively) of the IRF fabric.
<Sysname> mkdir chassis2#slot1#flash:/test
....
%Created dir chassis2#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.
At present, this command is valid only for text files.
Examples
# Display the contents of file test.txt.
<Sysname> more test.txt
Welcome to H3C.
mount
Syntax
mount device
View
User view
Default level
3: Manage level
Parameters
device: Name of a partition of a storage medium that has been partitioned.
Description
Use the mount command to mount a hot swappable storage medium, such as a CF card or a USB device (excluding flash). This command is effective only when the device is in unmounted state.
By default, a storage medium is automatically mounted and in mounted state after connected to the device, which means you can use it without mounting it.
Do not remove the storage medium or swap the card when mounting or unmounting the switch, 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 switch 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 switch.
Related commands: umount.
|
NOTE: To mount a storage medium that has been partitioned, mount each partition of the storage medium. For example, to mount a CF card that has been partitioned, you must mount each partition, instead of issuing the mount cfa0: command. |
Examples
# On a partitioned device, mount the CF card.
<Sysname> mount cf2cfa0:
% Mount cf2cfa0: successfully.
# Mount the third partition of the CF card on an SMB (the member ID and slot number of the member switch where the SMB resides are 2 and 1 respectively) of the IRF fabric.
<Sysname> mount chassis2#slot1#cfa2:
% Mount chassis2#slot1#cfa2: successfully.
%Apr 23 01:50:00:628 2008 Sysname VFS/5/LOG:
cfa2: mounted into chassis 2 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.
You cannot move files between storage media of different types or between different partitions of a CF card.
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, including files that cannot be deleted by the command without the /force keyword.
Description
Use the reset recycle-bin command to delete a file in the recycle bin.
If a file is corrupted, you may not be able to delete the file by using the reset recycle-bin command. In this case, you can use the reset recycle-bin /force command, which can delete all the files in the recycle bin forcibly.
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.
The reset recycle-bin command deletes files in the current directory and in the recycle bin. 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
# Delete file test.txt in the recycle bin.
1. Display all the files that are deleted from directory flash: to the recycle bin.
<Sysname> dir /all
Directory of flash:/
0 -rwh 1696 Jul 30 2007 11:11:35 private-data.txt
1 -rwh 4 Jul 12 2007 04:05:41 snmpboots
2 -rwh 716 Aug 20 2007 03:27:23 hostkey
3 -rwh 572 Aug 20 2007 03:27:29 serverkey
4 -rw- 299 Jul 16 2007 03:37:34 devicea.pub
5 -rwh 548 Aug 20 2007 03:29:30 dsakey
6 -rw- 375489 Jul 18 2007 09:03:19 cmdtree.txt
7 -rw- 41039544 Jul 18 2007 03:43:24 b05.bin
8 drw- - Jul 19 2007 08:31:59 test
9 -rw- 1577 Jul 30 2007 11:11:30 backup_new.cfg
10 -rw- 2579 Jul 30 2007 10:26:29 backup202.cfg
11 -rw- 19026768 Aug 07 2007 02:54:59 bt06.bin
12 -rw- 131072 Aug 23 2007 07:24:14 [test.txt]
129794 KB total (70622 KB free)
//The above information shows that among files in directory flash:, one file test.txt is removed to the recycle bin.
2. Execute the reset recycle-bin command in the current directory to delete files from the recycle bin.
<Sysname> reset recycle-bin
Clear flash:/~/test.txt ?[Y/N]:y
Clearing files from flash may take a long time. Please wait...
..
%Cleared file flash:/~/test.txt..
3. In directory flash:, check whether all the files deleted from this directory to the recycle bin are deleted.
<Sysname> dir /all
Directory of flash:/
0 -rwh 1696 Jul 30 2007 11:11:35 private-data.txt
1 -rwh 4 Jul 12 2007 04:05:41 snmpboots
2 -rwh 716 Aug 20 2007 03:27:23 hostkey
3 -rwh 572 Aug 20 2007 03:27:29 serverkey
4 -rw- 299 Jul 16 2007 03:37:34 devicea.pub
5 -rwh 548 Aug 20 2007 03:29:30 dsakey
6 -rw- 375489 Jul 18 2007 09:03:19 cmdtree.txt
7 -rw- 41039544 Jul 18 2007 03:43:24 b05.bin
8 drw- - Jul 19 2007 08:31:59 test
9 -rw- 1577 Jul 30 2007 11:11:30 backup_new.cfg
10 -rw- 2579 Jul 30 2007 10:26:29 backup202.cfg
11 -rw- 19026768 Aug 07 2007 02:54:59 bt06.bin
129794 KB total (70751 KB free)
// The output shows that file test.txt is deleted permanently.
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, delete all files and subfolders under it with the delete command.
After you execute the rmdir command successfully, the files deleted from the current folder to the recycle bin are automatically deleted.
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 partition of a storage medium that has been partitioned.
Description
Use the umount command to unmount a hot swappable storage medium, such as a CF card or a USB device, 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 mounted state. You must unmount it before removing it from the switch.
When mounting or unmounting a storage medium, or performing file operations on it, do not unplug or switchover the storage media 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 switch 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, first unmount it to avoid damaging the switch.
Related commands: mount.
|
NOTE: To unmount a storage medium that has been partitioned, unmount each partition of the storage medium. For example, to unmount a CF card that has been partitioned, you must unmount each partition, instead of issuing the umount cfa0: command . |
Examples
# Unmount the first partition on the CF card.
<Sysname> umount cfa0:
% Umount cfa0: successfully.
# Unmount the third partition of the CF card on an SMB (the member ID and slot number of the AMB of the member switch are 2 and 1 respectively) of the IRF fabric.
<Sysname> umount chassis2#slot1#cfa2:
% Umount chassis2#slot1#cfa2: successfully.
%Apr 23 01:49:20:929 2008 Sysname VFS/5/LOG:
cfa2: umounted from chassis 2 slot 1.
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 command overwrites the file and the system prompts you whether to continue.
Examples
# Restore file a.cfg in directory flash: from the recycle bin.
<Sysname> undelete a.cfg
Undelete flash:/a.cfg?[Y/N]:y
.....
# Restore file b.cfg in directory flash:/test from the recycle bin.
<Sysname> undelete flash:/test/b.cfg
Undelete flash:/test/b.cfg?[Y/N]:y
.......
%Undeleted file flash:/test/b.cfg.
Or, you can use the following steps to restore file flash:/test/b.cfg.
<Sysname> cd test
<Sysname> undelete b.cfg
Undelete flash:/test/b.cfg?[Y/N]:y
.....
%Undeleted file flash:/test/b.cfg.