- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
04-File System Management Commands | 93.30 KB |
File system management commands
Your device might have a Flash, a CF card, or both, depending on your device model. For more information, see About the H3C Access Controllers Configuration Guides.
In the following examples, the current working directory is the root directory of the storage medium on the device.
For information about the file name format requirements, see Fundamental Configuration Guide.
cd
Use cd to change the current working directory.
Syntax
cd { directory | .. | / }
Views
User view
Default command level
3: Manage level
Parameters
directory: Name of the target directory in the format [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 if no upper directory exists, the current working directory does not change when the cd .. command is executed. No online help information is available for this keyword.
/: Returns to the root directory of the storage medium. No online help information is available for this keyword.
Examples
# Enter the test folder after logging in to the device.
<Sysname> cd test
# Return to the upper directory. (A space is required after the keyword cd.)
<Sysname> cd ..
# Return to the root directory.
<Sysname> cd /
After you change the current directory by using the cd command, you can use the pwd command to view the path of the current working directory.
copy
Use copy to copy a file.
Syntax
copy fileurl-source fileurl-dest
Views
User view
Default command level
3: Manage level
Parameters
fileurl-source: Name of the source file.
fileurl-dest: Name of the target file or folder.
Usage guidelines
If you specify a target folder, the system will copy the file to the specified folder and use 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 cfa0:/test.cfg to cfa0:/testbackup.cfg?[Y/N]:y
....
%Copy file cfa0:/test.cfg to cfa0:/testbackup.cfg...Done.
crypto-digest
Use crypto-digest to calculate the digest of a file.
Syntax
crypto-digest sha256 file-url
Views
User view
Default command level
3: Manage level
Parameters
sha256: Uses the SHA-256 algorithm.
file-url: Specifies the name of a file.
Usage guidelines
The digest of a file can be used to verify the file integrity. For example, you can calculate the digest of a software image file and compare it with that provided on the H3C website to verify whether the file has been tampered with.
Examples
# Use the SHA-256 algorithm to calculate the digest of file cc.bin.
<Sysname> crypto-digest sha256 file cc.bin
Computing digest...
SHA256 digest(cc.bin)=
7bcb92458222f91f9a09a807c4c4567efd4d5dc4e4abc06c2a741df7045433eb
delete
Use delete file-url to temporarily delete a file.
Use delete /unreserved file-url to permanently delete a file.
Syntax
delete [ /unreserved ] file-url
Views
User view
Default command level
3: Manage level
Parameters
/unreserved: Permanently deletes the specified file. The deleted file cannot be restored anymore.
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, enter delete *.txt.
Usage guidelines
The delete file-url command moves a file to the recycle bin. To restore the file, use the undelete command.
If you delete two files that have the same file name from different directories, only the second file you deleted is retained in the recycle bin. The first file you deleted is permanently deleted.
The dir /all command displays the files moved to the recycle bin. These files are enclosed in pairs of square brackets [ ]. To permanently delete these files, use the reset recycle-bin command.
The delete /unreserved file-url command permanently deletes a file, and the deleted file cannot be restored.
Examples
# Remove file tt.cfg from the current directory.
<Sysname> delete tt.cfg
Delete cfa0:/tt.cfg? [Y/N]:y
%Delete file cfa0:/tt.cfg...Done.
dir
Use dir to display files or folders.
Syntax
dir [ /all ] [ file-url | /all-filesystems ]
Views
User view
Default command level
3: Manage level
Parameters
/all: Displays all files and folders in the current directory, including hidden files and folders, and 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, enter dir *.txt.
/all-filesystems: Displays files and folders in the root directory of all storage media on the device.
Usage guidelines
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 cfa0:/
0 -rw- 54047744 Oct 15 2012 15:38:40 wx6103.bin
1 -rw- 349 Oct 22 2012 11:10:32 system.xml
2 -rw- 1914 Oct 22 2012 11:10:34 startup.cfg
3 -rw- 1695 Jan 27 2011 16:36:50 [test.cfg]
1020068 KB total (831136 KB free)
File system type of cfa0: FAT32
[ ] indicates this file is in the recycle bin.
# Display files and folders in the root directory of all storage media on the device.
<Sysname> dir /all-filesystems
Directory of cfa0:/
0 -rw- 54047744 Oct 15 2012 15:38:40 wx6103.bin
1 -rw- 349 Oct 22 2012 11:10:32 system.xml
2 -rw- 1914 Oct 22 2012 11:10:34 startup.cfg
1020068 KB total (831136 KB free)
File system type of cfa0: FAT32
Table 1 Command output
Field |
Description |
Directory of |
Current working directory. |
d |
Directory. This field is not displayed for 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
Use execute to execute the specified batch file.
Syntax
execute filename
Views
System view
Default command level
2: System level
Parameters
filename: Name of a batch file with the .bat extension. To change the extension of a configuration file to .bat, use the rename command.
Usage guidelines
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 will abort and the commands that have been executed cannot be cancelled.
Not every command in a batch file will be executed. For example, if a command is not configured correctly, the system will not execute the command but skips the command and moves to the next command.
Each configuration command in a batch file must be a standard configuration command. The valid configuration information can be displayed with the display current-configuration command.
Examples
# Execute the batch file test.bat in the root directory.
<Sysname> system-view
[Sysname] execute test.bat
file prompt
Use file prompt to set the file operation mode.
Syntax
file prompt { alert | quiet }
Default
The operation mode is alert.
Views
System view
Default command level
3: Manage level
Parameters
alert: Enables the system to warn you about operations that might cause problems such as file corruption or data loss.
quiet: Disables the system from warning you about any operation.
Usage guidelines
When the operation mode is set to quiet, the system does not warn for any file operation. To avoid problems, use the alert mode.
Examples
# Set the file system operation mode to alert.
<Sysname> system-view
[Sysname] file prompt alert
fixdisk
Use fixdisk to examine a storage medium for damage and repair any damage.
Syntax
fixdisk device
Views
User view
Default command level
3: Manage level
Parameters
device: Storage medium name.
Usage guidelines
Use this command to fix a storage medium when the medium becomes unavailable or cannot operate correct.
Examples
# Examine the CF card for damage and repair the damage.
<Sysname> fixdisk cfa0:
%Fixdisk cfa0: completed.
format
Use format to format a storage medium.
Syntax
format device [ FAT16 | FAT32 ]
Views
User view
Default command level
3: Manage level
Parameters
device: Storage medium name.
FAT16: Formats the storage medium using the FAT16 format. To use this keyword, you must enter the entire keyword. Pressing the Tab key after entering part of the keyword cannot complete the keyword. This keyword is not applicable to the Flash memory.
FAT32: Formats the storage medium using the FAT32 format. To use this keyword, you must enter the entire keyword. Pressing the Tab key after entering part of the keyword cannot complete the keyword. This keyword is not applicable to the Flash memory.
Usage guidelines
After a storage medium is formatted, all files on the medium are erased and cannot be restored. If a startup configuration file exists on the storage medium, formatting the storage medium results in loss of the startup configuration file.
Examples
# Format the CF card.
<Sysname> format cfa0:
All data on cfa0: will be lost, proceed with format? [Y/N]:y
./
%Format cfa0: completed.
# Format the CF card using the FAT32 format.
<Sysname> format cfa0: FAT32
mkdir
Use mkdir to create a folder under a specified directory on the storage medium.
Syntax
mkdir directory
Views
User view
Default command level
3: Manage level
Parameters
directory: Name of a folder.
Usage guidelines
The name of the folder must be different from the name of any other folder in the same directory.
To create a folder in a directory, make sure the directory already exists. For example, to create folder mytest in the directory cfa0:/test, the directory cfa0:/test must already exist.
Examples
# Create a folder named test in the current directory.
<Sysname> mkdir test
....
%Created dir cfa0:/test
# Create folder test/subtest in the current directory.
<Sysname> mkdir test/subtest
....
%Created dir cfa0:/test/subtest
more
Use more to display the contents of a file.
Syntax
more file-url [ | { begin | exclude | include } regular-expression ]
Views
User view
Default command level
3: Manage level
Parameters
file-url: File name.
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Usage guidelines
It the content does not fit on one screen:
· Press Enter to display the next line.
· Press Space to display the next screen.
· Press Ctrl+C or any other key to exit the display.
This command is only applicable to text files.
Examples
# Display the contents of file test.txt.
<Sysname> more 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>
move
Use move to move a file.
Syntax
move fileurl-source fileurl-dest
Views
User view
Default command level
3: Manage level
Parameters
fileurl-source: Name of the source file.
fileurl-dest: Name of the target file or folder.
Usage guidelines
If you specify a target folder, the system moves the source file to the specified folder without changing the file name.
Examples
# Move file cfa0:/test/sample.txt to cfa0:/, and save it as 1.txt.
<Sysname> move test/sample.txt 1.txt
Move cfa0:/test/sample.txt to cfa0:/1.txt?[Y/N]:y
...
% Moved file cfa0:/test/sample.txt to cfa0:/1.txt
# Move file b.cfg to the subfolder test2.
<Sysname> move b.cfg test2
Move cfa0:/b.cfg to cfa0:/test2/b.cfg?[Y/N]:y
.
%Moved file cfa0:/b.cfg to cfa0:/test2/b.cfg.
pwd
Use pwd to display the current path.
Syntax
pwd
Views
User view
Default command level
3: Manage level
Examples
# Display the current path.
<Sysname> pwd
cfa0:
rename
Use rename to rename a file or folder.
Syntax
rename fileurl-source fileurl-dest
Views
User view
Default command level
3: Manage level
Parameters
fileurl-source: Name of the source file or folder.
fileurl-dest: Name of the target file or folder.
Usage guidelines
The target file name must be different from the name of any other file in the same directory, and the target folder name must be different from the name of any other folder in the same directory.
Examples
# Rename file sample.txt as sample.bat.
<Sysname> rename sample.txt sample.bat
Rename cfa0:/sample.txt to cfa0:/sample.bat? [Y/N]:y
% Renamed file cfa0:/sample.txt to cfa0:/sample.bat
reset recycle-bin
Use reset recycle-bin to permanently delete the files in the recycle bin in the current directory.
Syntax
reset recycle-bin [ /force ]
Views
User view
Default command 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.
Usage guidelines
The reset recycle-bin command might not be able to delete a corrupted file. To delete corrupted files, use the reset recycle-bin /force command.
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
# Permanently delete file b.cfg from the current directory:
1. Display all files in the current directory.
<Sysname> dir /all
Directory of cfa0:/
0 -rw- 54047744 Oct 15 2012 15:38:40 wx6103.bin
1 -rw- 349 Oct 22 2012 11:10:32 system.xml
2 -rw- 1914 Oct 22 2012 11:10:34 startup.cfg
3 drw- - Jan 21 2011 14:11:52 test
4 -rw- 2386 May 08 2008 11:14:20 [a.cfg]
5 -rw- 3608 Dec 03 2007 17:29:30 [b.cfg]
1020068 KB total (831136 KB free)
File system type of cfa0: FAT32
//The output shows that the current directory is cfa0:, and files a.cfg and b.cfg are in the recycle bin.
2. Delete file b.cfg from the recycle bin.
<Sysname> reset recycle-bin
Clear cfa0:/~/a.cfg ?[Y/N]:n
Clear cfa0:/~/b.cfg ?[Y/N]:y
......
%Cleared file cfa0:/~/b.cfg...
3. Verify whether or not the file b.cfg was deleted.
<Sysname> dir /all
Directory of cfa0:/
0 -rw- 54047744 Oct 15 2012 15:38:40 wx6103.bin
1 -rw- 349 Oct 22 2012 11:10:32 system.xml
2 -rw- 1914 Oct 22 2012 11:10:34 startup.cfg
3 drw- - Jan 21 2011 14:11:52 test
4 -rw- 2386 May 08 2008 11:14:20 [a.cfg]
1020068 KB total (831176 KB free)
File system type of cfa0: FAT32
// The output shows that file cfa0:/b.cfg was deleted permanently.
# Permanently delete file aa.cfg from the subdirectory test:
1. Enter the subdirectory.
<Sysname> cd test/
2. Display all files in the subfolder test.
<Sysname> dir /all
Directory of cfa0:/test
0 -rw- 2161 Apr 26 2000 21:22:35 [aa.cfg]
1020068 KB total (831186 KB free)
// The output shows that only one file exists in the folder, and the file has been moved to the recycle bin.
3. Delete file test/aa.cfg from the recycle bin.
<Sysname> reset recycle-bin
Clear cfa0:/test/~/aa.cfg ?[Y/N]:y
..
%Cleared file cfa0:/test/~/aa.cfg...
rmdir
Use rmdir to remove a folder.
Syntax
rmdir directory
Views
User view
Default command level
3: Manage level
Parameters
directory: Name of the folder.
Usage guidelines
The folder must be empty. If not, delete all files and subfolders under it by using the delete command.
After you execute the rmdir command successfully, the files in the recycle bin in the folder will be automatically deleted.
Examples
# Remove folder mydir.
<Sysname> rmdir mydir
Rmdir cfa0:/mydir?[Y/N]:y
%Removed directory cfa0:/mydir.
undelete
Use undelete to restore a file from the recycle bin.
Syntax
undelete file-url
Views
User view
Default command level
3: Manage level
Parameters
file-url: Name of the file to be restored.
Usage guidelines
If another file with the same name exists in the same path, you can choose whether to overwrite the existing file or cancel the operation.
Examples
# Restore file a.cfg in directory cfa0: from the recycle bin.
<Sysname> undelete a.cfg
Undelete cfa0:/a.cfg?[Y/N]:y
.....
%Undeleted file cfa0:/a.cfg.
# Restore file b.cfg in directory cfa0:/test from the recycle bin.
<Sysname> undelete cfa0:/test/b.cfg
Undelete cfa0:/test/b.cfg?[Y/N]:y
.......
%Undeleted file cfa0:/test/b.cfg.
Or:
<Sysname> cd test
<Sysname> undelete b.cfg
Undelete cfa0:/test/b.cfg?[Y/N]:y
.....