- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
04-File System Management Commands | 116.93 KB |
In the following examples, the current working directory is the root directory of the storage medium on the device.
For information about the qualified file name formats, see Fundamentals 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 flash:/test.cfg to flash:/testbackup.cfg?[Y/N]:y
....
%Copy file flash:/test.cfg to flash:/testbackup.cfg...Done.
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, 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, 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 with the same file name in different directories, only the last one is retained in the recycle bin.
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 flash:/tt.cfg? [Y/N]:y
.
%Delete file flash:/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, 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, enter dir *.txt.
/all-filesystems: Displays files and folders in the root directories 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 flash:/
0 drw- 6985954 Apr 26 2007 21:06:29 logfile
1 -rw- 1842 Apr 27 2007 04:37:17 mainup.app
2 -rw- 1518 Apr 26 2007 12:05:38 config.cfg
3 -rw- 2045 May 04 2007 15:50:01 backcfg.cfg
4 -rwh 428 Apr 27 2007 16:41:21 hostkey
5 -rwh 572 Apr 27 2007 16:41:31 serverkey
6 -rw- 2737556 Oct 12 2007 01:31:44 [old.app]
15057 KB total (4934 KB free)
A file in a pair of square brackets ([ ]) is in the recycle bin.
# Display files and folders in the root directories of all storage media on the device.
<Sysname> dir /all-filesystems
Directory of flash:/
0 -rw- 1520300 Dec 01 2010 11:37:47 cmdtree.txt
1 drw- - Dec 01 2010 11:37:41 logfile
2 drw- - Dec 01 2010 15:07:15 diaglog
3 drw- - Dec 01 2010 15:07:15 seclog
4 drw- - Dec 03 2010 09:48:05 secl
5 -rw- 909 Dec 03 2010 09:48:38 secl.log
6 -rw- 302515 Dec 09 2010 15:18:09 default.diag
15057 KB total (4934 KB free)
Table 1 Command output
Field |
Description |
Directory of |
Current working directory. |
d |
Directory. This field does not exist 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 is sure to be executed. For example, if a certain command is not correctly configured, the command will not be executed, and the system skips this command and goes to the next one.
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.
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 bring undesirable results 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 misoperation, 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 normally.
Examples
# Examine the Flash for damage and repair any damage.
<Sysname> fixdisk flash:
Fixdisk flash: may take some time to complete...
%Fixdisk flash: completed.
format
Use format to format a storage medium.
Syntax
format device
Views
User view
Default command level
3: Manage level
Parameters
device: Name of a storage medium (for example, flash:).
Usage guidelines
After a storage medium is formatted, all files on it 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 Flash.
<Sysname> format flash:
All data on flash: will be lost, proceed with format? [Y/N]:y
./
%Format flash: completed.
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 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 example, to create folder flash:/test/mytest, the test folder must exist. Otherwise, you will fail to create the mytest folder.
Examples
# Create a folder named test in the current directory.
<Sysname> mkdir test
....
%Created dir flash:/test
# Create folder test/subtest in the current directory.
<Sysname> mkdir test/subtest
....
%Created dir flash:/test/subtest
more
Use more to display the contents of a file.
Syntax
more file-url
Views
User view
Default command level
3: Manage level
Parameters
file-url: File name.
Usage guidelines
It the content is more than will fit on one screen:
· Pressing Enter displays the next line.
· Pressing Space displays the next screen.
· Pressing Ctrl+C or any other key exits 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 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
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
flash:
rename
Use rename to rename a file or folder. The target file name must be unique in the current path.
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.
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
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
If a file is corrupted, you might 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 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 b.cfg in the current directory and in the recycle bin:
1. Display all files in the recycle bin or in the current directory.
<Sysname> dir /all
Directory of flash:/
0 -rwh 3080 Apr 26 2008 16:41:43 private-data.txt
1 -rw- 2416 Apr 26 2008 13:45:36 config.cfg
2 -rw- 8036197 May 14 2008 10:13:18 main.app
3 -rw- 2386 Apr 26 2008 13:30:30 back.cfg
4 drw- - May 08 2008 09:49:25 test
5 -rwh 716 Apr 24 2007 16:17:30 hostkey
6 -rwh 572 Apr 24 2007 16:17:44 serverkey
7 -rw- 2386 May 08 2008 11:14:20 [a.cfg]
8 -rw- 3608 Dec 03 2007 17:29:30 [b.cfg]
15057 KB total (4934 KB free)
//The output shows that the current directory is flash:, and there are two files a.cfg and b.cfg in the recycle bin.
2. Delete file b.cfg in the current directory and in the recycle bin.
<Sysname> reset recycle-bin
Clear flash:/~/a.cfg ?[Y/N]:n
Clear flash:/~/b.cfg ?[Y/N]:y
Clearing files from flash may take a long time. Please wait...
......
%Cleared file flash:/~/b.cfg...
3. In directory flash:, check whether the file b.cfg has been deleted from the recycle bin.
<Sysname> dir /all
Directory of flash:/
0 -rwh 3080 Apr 26 2008 16:41:43 private-data.txt
1 -rw- 2416 Apr 26 2008 13:45:36 config.cfg
2 -rw- 8036197 May 14 2008 10:13:18 main.app
3 -rw- 2386 Apr 26 2008 13:30:30 back.cfg
4 drw- - May 08 2008 09:49:25 test
5 -rwh 716 Apr 24 2007 16:17:30 hostkey
6 -rwh 572 Apr 24 2007 16:17:44 serverkey
7 -rw- 2386 May 08 2008 11:14:20 [a.cfg]
15057 KB total (6934 KB free)
// The output shows that file flash:/b.cfg is deleted permanently.
# Delete file aa.cfg in the subdirectory test and in the recycle bin:
1. Enter the subdirectory.
<Sysname> cd test/
2. Display all files in the subfolder test.
<Sysname> dir /all
Directory of flash:/test
0 -rw- 2161 Apr 26 2000 21:22:35 [aa.cfg]
14605 KB total (6734 KB free)
// The output shows that only one file exists in the folder, and the file has been moved to the recycle bin.
3. Permanently delete file test/aa.cfg.
<Sysname> reset recycle-bin
Clear flash:/test/~/aa.cfg ?[Y/N]:y
Clearing files from flash may take a long time. Please wait...
..
%Cleared file flash:/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 an empty one. 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 flash:/mydir?[Y/N]:y
%Removed directory flash:/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, the system prompts you on whether to overwrite the original file.
Examples
# Restore file a.cfg in directory flash: from the recycle bin.
<Sysname> undelete a.cfg
Undelete flash:/a.cfg?[Y/N]:y
.....
%Undeleted file flash:/a.cfg.
# 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:
<Sysname> cd test
<Sysname> undelete b.cfg
Undelete flash:/test/b.cfg?[Y/N]:y
.....