华为网络设备的配置文件和VRP系统文件都保存在物理存储介质中,所以文件系统是VRP正常运行的基础。只有掌握了对文件系统的基本操作,网络工程师才能对设备的配置文件和VRP系统文件进行高效的管理。
VRP系统是 基于linux开发的,一些命令和linux命令一样。
一、基本查询命令
dir //查看当前目录下的文件信息
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - Oct 22 2018 06:22:51 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 Oct 22 2018 06:22:42 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 ssl***.zip
1,090,732 KB total (784,464 KB free)
pwd //查看当前目录,此时属于flash: 根目录下
flash:
二、目录操作
cd dhcp //进入dhcp的文件夹下
pwd //查看当前目录
flash:/dhcp
cd .. //返回根目录
pwd
flash:
mkdir test //创建新的目录,名称为test
Info: Create directory flash:/test......Done
dir //查看是否创建成功。
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - Oct 22 2018 06:36:50 test ----已创建成功
1 drw- - Oct 22 2018 06:22:51 dhcp
2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
3 -rw- 2,263 Oct 22 2018 06:22:42 statemach.efs
4 -rw- 828,482 May 26 2014 09:20:58 ssl***.zip
1,090,732 KB total (784,460 KB free)
rmdir test //删除目录test
Remove directory flash:/test? (y/n)[n]:y
%Removing directory flash:/test...Done!
三、文件操作
cd dhcp
dir
Directory of flash:/dhcp/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:22:51 dhcp-duid.txt
1,090,732 KB total (784,460 KB free)
more dhcp-duid.txt //查看文本文件具体内容
*Huawei DHCP DUID*
*time* 2018-10-22 14:22:51
*version* 1
#DUID_LL: 0003000100E0FCDD6E80
*end*
copy dhcp-duid.txt flash:/test //复制dhcp-duid.txt 到test文件夹下
Copy flash:/dhcp/dhcp-duid.txt to flash:/test/dhcp-duid.txt? (y/n)[n]:y
100% complete
Info: Copied file flash:/dhcp/dhcp-duid.txt to flash:/test/dhcp-duid.txt...Done
cd flash:/test
dir
Directory of flash:/test/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:43:31 dhcp-duid.txt ----复制成功
1,090,732 KB total (784,452 KB free)
pwd
flash:/test
rename dhcp-duid.txt qytang.txt //把dhcp.-duid.txt 重命名为qytang.txt
Rename flash:/test/dhcp-duid.txt to flash:/test/qytang.txt? (y/n)[n]:y
Info: Rename file flash:/test/dhcp-duid.txt to flash:/test/qytang.txt ......Done
dir
Directory of flash:/test/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:43:31 qytang.txt ----重命名成功
1,090,732 KB total (784,456 KB free)
move qytang.txt flash:/dhcp //把qytang.txt 文本移动到dhcp的文件夹下,类似于剪切功能。move命令只适用于在同一储存设备中移动文件。
Move flash:/test/qytang.txt to flash:/dhcp/qytang.txt? (y/n)[n]:y
%Moved file flash:/test/qytang.txt to flash:/dhcp/qytang.txt.
dir
Info: File can't be found in the directory
1,090,732 KB total (784,456 KB free)
cd flash:/dhcp
dir
Directory of flash:/dhcp/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:22:51 dhcp-duid.txt
1 -rw- 98 Oct 22 2018 06:43:31 qytang.txt ----移动成功
1,090,732 KB total (784,456 KB free)
四、文件操作
delete dhcp-duid.txt //删除文件
Delete flash:/dhcp/dhcp-duid.txt? (y/n)[n]:y
Info: Deleting file flash:/dhcp/dhcp-duid.txt...succeed.
dir //查看文件
Directory of flash:/dhcp/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:43:31 qytang.txt
1,090,732 KB total (784,452 KB free)
dir /all //查看所有文件,包括删除的文件,此时删除的文件被放到回收站里面
Directory of flash:/dhcp/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:43:31 qytang.txt
1 -rw- 98 Oct 22 2018 06:56:23 [dhcp-duid.txt] ----[]中括号表示的被放到回收站的文件。
1,090,732 KB total (784,452 KB free)
undelete dhcp-duid.txt //恢复删除的文件
Undelete flash:/dhcp/dhcp-duid.txt? (y/n)[n]:y
%Undeleted file flash:/dhcp/dhcp-duid.txt.
dir /all
Directory of flash:/dhcp/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:22:51 dhcp-duid.txt ---此文件已经恢复
1 -rw- 98 Oct 22 2018 06:43:31 qytang.txt
1,090,732 KB total (784,452 KB free)
delete /unreserved dhcp-duid.txt //永久删除文件,不放到回收站中
Warning: The contents of file flash:/dhcp/dhcp-duid.txt cannot be recycled. Continue? (y/n)[n]:y
Info: Deleting file flash:/dhcp/dhcp-duid.txt...
Deleting file permanently from flash will take a long time if needed...succeed.
dir /all ----此时该文件夹下没有dhcp.duid.txt
Directory of flash:/dhcp/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 06:43:31 qytang.txt
1,090,732 KB total (784,456 KB free)
delete qytang.txt
Delete flash:/dhcp/qytang.txt? (y/n)[n]:y
Info: Deleting file flash:/dhcp/qytang.txt...succeed.
dir /all
Directory of *
Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 98 Oct 22 2018 07:03:01 [qytang.txt] ---删除文件,放进回收站
1,090,732 KB total (784,456 KB free)
reset recycle-bin //彻底删除回收站中内容
Squeeze flash:/dhcp/qytang.txt? (y/n)[n]:y
Clear file from flash will take a long time if needed...Done.
%Cleared file flash:/dhcp/qytang.txt.
dir /all
Info: File can't be found in the directory
1,090,732 KB total (784,460 KB free)
五、配置文件管理
设备中的配置文件分为两种类型:当前配置文件和保存的配置文件。当前配置文件储存在设备的RAM中。用户可以通过命令行对设备进行配置,配置完成后使用save命令保存当前配置到存储设备中,形成保存的配置文件。
保存的配置文件都是以“.cfg”或“.zip”作为扩展名,存放在存储设备的根目录下。
在设备启动时,会从默认的存储路径下加载保存的配置文件到RAM中。如果默认存储路径中没有保存的配置文件,则设备会使用缺省参数进行初始化配置。
display current-configuration //查看当前配置
[V200R003C00]
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
……
dis saved-configuration //初始化启动的设备还没有保存,此时无保存配置
There is no correct configuration file in FLASH
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]sysname QYTANG //修改设备名称为QYTANG
save //保存当前配置信息
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait........
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
display saved-configuration //查看保存的配置文件
[V200R003C00]
#
sysname QYTANG
#
……
dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - Oct 22 2018 06:51:39 test
1 drw- - Oct 22 2018 07:03:01 dhcp
2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
3 -rw- 2,263 Oct 22 2018 06:22:42 statemach.efs
4 -rw- 828,482 May 26 2014 09:20:58 ssl***.zip
5 -rw- 352 Oct 22 2018 07:12:00 private-data.txt
6 -rw- 557 Oct 22 2018 07:11:59 vrpcfg.zip ---保存的配置文件名称为vrpcfg.zip
1,090,732 KB total (784,452 KB free)
reset saved-configuration //清除下次启动时加载的配置文件
This will delete the configuration in the flash memory.
The device configurations will be erased to reconfigure.
Are you sure? (y/n)[n]:y ---输入y
Clear the configuration in the device successfully.
reboot //重启设备
Info: The system is comparing the configuration, please wait.
Warning: All the configuration will be saved to the next startup configuration. Continue ? [y/n]:n //注意此时要输入n,不然配置还会保存,启动时会加载保存的配置文件
System will reboot! Continue ? [y/n]:y //输入 y 重启设备
Info: system is rebooting ,please wait...