- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
04-File system management commands | 119.42 KB |
In the examples in this chapter, the current working directory refers to the root directory of the storage medium on the device.
For information about the qualified file name formats, 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: Specifies the name of the target directory in the format of [drive:/]path. For the detailed introduction to 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 cd .. is executed. This argument does not support command online help.
/: Returns to the root directory of the storage medium. This keyword does not support command line online help.
Usage guidelines
Use this command to change the current working directory. To display the current working directory, use the pwd command.
Examples
# Enter the test folder from the current directory.
<Sysname> cd test
# Return to the upper directory. Note that a space is required after cd.
<Sysname> cd ..
# Return to the root directory.
<Sysname> cd /
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: Specifies the name of the source file.
fileurl-dest: Specifies the 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 the 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.
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: Specifies the 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, use the delete *.txt command.
Usage guidelines
The delete file-url command moves a file to the recycle bin. To restore the file, use the undelete command.
|
CAUTION: 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 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 root directory of the storage medium.
<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, 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, use the dir *.txt command.
/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 on the storage medium.
<Sysname> dir /all
Directory of flash:/
0 -rwh 4 JAN 26 2013 12:02:05 snmpboots
1 -rw- 10187730 JAN 26 2013 16:47:07 startup.bin
2 -rwh 3144 JAN 26 2013 13:45:35 private-data.txt
3 -rw- 2161 JAN 26 2013 13:53:25 startup.cfg
4 -rw- 10058752 JAN 19 2013 17:41:46 startup_b58.bin
5 -rw- 10139143 JAN 26 2013 13:08:20 startup_b59.bin
6 -rwh 716 JAN 26 2013 12:01:58 hostkey
7 -rwh 572 JAN 26 2013 12:02:11 serverkey
8 -rwh 548 JAN 26 2013 12:02:17 dsakey
9 -rw- 3035 JAN 26 2013 13:45:42 new-config.cfg
10 -rw- 2200 JAN 26 2013 14:58:35 [aa.cfg]
12065 KB total (9076 KB free)
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 a batch file.
Syntax
execute filename
Views
System view
Default command level
2: System level
Parameters
filename: Specifies the 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
A batch file contains a set of commands. Executing a batch file is to execute the commands 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 certain command is not correctly configured, the command fails to be executed, and the system skips the 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 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: Specifies the 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: Specifies the name of a storage medium, for example, flash.
Usage guidelines
Formatting a storage medium results in loss of all files on the storage medium and these files cannot be restored. In particular, if a startup configuration file exists on a 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 directory on the storage medium.
Syntax
mkdir directory
Views
User view
Default command level
3: Manage level
Parameters
directory: Specifies the path information and the folder name.
Usage guidelines
To create a folder under the current directory, specify solely the folder name. To create a folder under another directory, specify the path information as well as the folder name.
The folder name must be unique in the specified directory and the directories specified in the path information must already exist. For example, to create folder flash:/test/mytest, the test directory must exist.
Examples
# Create folder 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: Specifies the file name.
Usage guidelines
When the output is more than will fit on one screen, the system automatically pauses after displaying a 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 valid only for text files.
Examples
# Display the contents of file testcfg.cfg.
<Sysname> more testcfg.cfg
#
version 5.20, Release 0000
#
sysname Test
#
---- More ----
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: Specifies the name of the source file.
fileurl-dest: Specifies the name of the target file or folder.
Usage guidelines
If you specify a target folder, the system will move the source file to the specified folder, with the file name unchanged.
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: Specifies the name of the source file or folder.
fileurl-dest: Specifies the 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 and in the current directory.
<Sysname> dir /all
Directory of flash:/
0 -rwh 3080 JAN 26 2013 16:41:43 private-data.txt
1 -rw- 2416 JAN 26 2013 13:45:36 config.cfg
2 -rw- 8036197 JAN 14 2013 10:13:18 main.bin
3 -rw- 2386 JAN 26 2013 13:30:30 back.cfg
4 drw- - JAN 08 2013 09:49:25 test
5 -rwh 716 JAN 24 2013 16:17:30 hostkey
6 -rwh 572 JAN 24 2013 16:17:44 serverkey
7 -rw- 2386 JAN 08 2013 11:14:20 [a.cfg]
8 -rw- 3608 JAN 03 2013 17:29:30 [b.cfg]
12065 KB total (6730 KB free)
//The output shows that the current directory is flash:. Files a.cfg and b.cfg are 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:, verify whether the file b.cfg has been deleted from the recycle bin.
<Sysname> dir /all
Directory of flash:/
0 -rwh 3080 JAN 26 2013 16:41:43 private-data.txt
1 -rw- 2416 JAN 26 2013 13:45:36 config.cfg
2 -rw- 8036197 JAN 14 2013 10:13:18 main.bin
3 -rw- 2386 JAN 26 2013 13:30:30 back.cfg
4 drw- - JAN 08 2013 09:49:25 test
5 -rwh 716 JAN 24 2013 16:17:30 hostkey
6 -rwh 572 JAN 24 2013 16:17:44 serverkey
7 -rw- 2386 JAN 08 2013 11:14:20 [a.cfg]
12065 KB total (6734 KB free)
// The output shows that file flash:/b.cfg has been deleted permanently.
# Delete file aa.cfg in the subdirectory test and in the recycle bin:
4. Enter the subdirectory
<Sysname> cd test/
5. View all files in the subfolder test.
<Sysname> dir /all
Directory of flash:/test
0 -rw- 2161 JAN 26 2013 21:22:35 [aa.cfg]
12065 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.
6. 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: Specifies the name of the folder.
Usage guidelines
The folder must be an empty one. If not, delete all files and subfolders under it 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: Specifies the 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 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
.....
%Undeleted file flash:/test/b.cfg.