取消
显示结果 
搜索替代 
您的意思是: 
cancel
2736
查看次数
0
有帮助
0
评论
Pengfei Yu
Enthusiast
Enthusiast

常用的Cisco IOS文件管理命令

#1 dir

这条指令用来显示文件夹下的文件列表,输入dir ? 可以查看可选参数。如下所示:

/all List all files

/recursive List files recursively

all-filesystems List files on all filesystems

archive: Directory or file name

cns: Directory or file name

flash: Directory or file name

Null: Directory or file name

nvram: Directory or file name

system: Directory or file name

tar: Directory or file name

tmpsys: Directory or file name

xmodem: Directory or file name

ymodem: Directory or file name

Router#

以上每一种文件系统(比如flashnvram等带冒号的)都相当于 DOS系统里的磁盘分区,你需要在其名称后面加冒号。默认情况下,dir会列出路由器flash中的文件,因为默认的当前路径就是flash: 

Router# dir

Directory of flash:/

2 -rwx 18929780 Aug 29 2006 15:49:57 +00:00 c870-advipservicesk9-mz.124-15.T5.bin

3 -rwx 2143 Aug 29 2006 16:42:14 +00:00 running-config

23482368 bytes total (4544512 bytes free)

Router#

每个路由器至少都会包含flash内存和nvram 内存。

#2 cd [filesystem:]    <<<<改变默认目录或文件系统;

你可以使用 cd 命令改变当前所在的路径。在下面的例子里,将路径改到了nvram文件系统下,并通过dir命令列出了nvram内存中的文件。我还可以使用mkdir建立一个文件夹,并用 cd 命令进入该文件夹。

Router#cd nvram:

Router#dir

Directory of nvram:/

126 -rw- 2143 startup-config

127 ---- 5 private-config

128 -rw- 2143 underlying-config

1 ---- 49 persistent-data

2 -rw- 0 ifIndex-table

131072 bytes total (116584 bytes free)

Router#

#3 copy

这个命令用来将 IOS 或一个配置文件拷贝到某处。你可以用这个命令将路由器配置文件拷贝到 TFTP服务器上,或者拷贝到路由器里的某个文件夹中作为备份。你还可以用 copy 命令将新的IOS 文件从TFTP服务器拷贝到路由器里,实现路由器升级。

copy system:running-config nvram:startup-config

这里我使用copy命令为路由器建立一个本地的配置备份:

Router#copy running-config davids-backup-before-upgrade

Destination filename [davids-backup-before-upgrade]?

2181 bytes copied in 3.052 secs (715 bytes/sec)

Router#

#4 delete rm

这两个命令都很简单 delete 用来删除文件, rm 用来删除文件夹。比如我用delete命令删除我刚刚创建的配置备份文件:

Router#delete davids-backup-before-upgrade

Delete filename [davids-backup-before-upgrade]?

Delete flash:/davids-backup-before-upgrade? [confirm]

Router#

#5 show flash

这个命令用来显示flash中的文件。show flash 命令和 dir flash 命令类似,但是前者比后者显示出的信息更丰富一些,即多出了flash内存大小和类型信息

Router#show flash

24576K bytes of processor board System flash (Intel Strataflash)

Directory of flash:/

2 -rwx 18929780 Aug 29 2006 15:49:57 +00:00 c870-advipservicesk9-mz.124-15.T5.bin

3 -rwx 2181 Oct 4 2006 04:03:00 +00:00 mybackup-today

23482368 bytes total (4544512 bytes free)

Router#

#6 erase format

要弄懂为什么要erase 一种文件系统,而format 另一种系统,可能会比较麻烦。所以你只需要知道应该format flash中的文件系统,而erase nvram里的文件系统。其余文件则根据其类型既可以erase又可以formaterase 命令大多数时候都是用在清除路由器配置,恢复出场配置的情况。具体的命令就是 erase startup-configuration

Router# erase ?

/all Erase all files(in NVRAM)

/no-squeeze-reserve-space Do not reserve space for squeeze operation

flash: Filesystem to be erased

nvram: Filesystem to be erased

startup-config Erase contents of configuration memory

Router# format ?

flash: Filesystem to be formatted

Router#

#7 more

这个命令可以显示文本/配置文件的内容。比如你想查看一个备份的配置文件,就可以使用more 命令来查看该文件的内容:

Router# more my-backup-config

!

version 12.4

parser config cache interface

parser config interface

{config truncated}

 #8 verify

这个命令用来核查或者计算一个文件的MD5校验和。

Router#verify flash:c870-advipservicesk9-mz.124-15.T5.bin

Verifying file integrity of flash:c870-advipservicesk9-mz.124-15.T5.bin................... Done!

Embedded Hash MD5 : CA8AEC573B197AEC6BD5892DE23C4754

Computed Hash MD5 : CA8AEC573B197AEC6BD5892DE23C4754

CCO Hash MD5 : 9D39672246853C0F31533B6BCB21DFE5

Embedded hash verification successful.

File system hash verification failed for file flash:c870-advipservicesk9-mz.

124-15.T5.bin(No such file or directory).

Router#

#9 mkdir

DOS环境一样,你也可以在路由器中使用 mkdir 命令创建文件夹。一般我用这个命令来创建备份文件夹,用来存储配置文件或者ISO文件的备份。

Router# mkdir backup-configs

Create directory filename [backup-configs]?

Created dir flash:backup-configs

Router#

#10 fsck    <<<<只针对C filesystem

FAT 文件系统检测主要是用来检测flash文件系统的完整性。如果你感觉ISO文件有损坏,可以通过这个命令对文件系统进行检查。

Router# fsck

Fsck operation may take a while. Continue? [confirm]

............

Fsck of flash: complete

Router#

-------------------------------------------------------------------------------------------------------------------------

Router#show file systems     <<<<Displays more information about each of the files on a file system;

Router#show bootvar EXEC     <<<< To view the contents of environment variables;

Displays the BOOT environment variable,

the CONFIG_FILE environment variable,

the BOOTLDR environment variable,

 and the configuration register setting.

Router(config)#boot config      <<<<To modify the CONFIG_FILE environment variable;

Specifies the device and filename of the configuration file from which the

router configures itself during initialization (startup).

Router(config)#boot bootldr     <<<<To modify the BOOTLDR environment variable;

Router(config)#boot system     <<<<To modify the BOOT environment variable;

 Specifies the system image that the router loads at startup.

Router#copy system:running-config nvram:startup-config <<<< To save your modifications;

##################################################################

ip ftp username         <<<<FTP传输必要配置;

ip ftp password

copy bootflash:XYZ.bin ftp://myuser:mypass@172.23.1.129/c3600-i-mz

##################################################################

Command    Filesystem        Description

Delete     ALL          Marks the files as deleted, but does not permanently remove them from flash.

Squeeze     A              Permanently removes all files that have been marked as deleted.

Format     A and C          Erases the entire flash device.

Verify     ALL             Verifies that the IOS files checksum matches the value encoded in the image.

Undelete    A and B          Recovers deleted files.

Erase      A and B          Erases the entire flash device.

 Switch#delete /force /recursive filesystem:/file-url<<<<删除文件夹内所有文件;

             使用/recursive关键字删除指定的目录及其所有子目录和其中包含的文件。

        使用/force关键字来抑制提示,避免删除目录中的一个文件提示一次;

 

This example shows how to create a file. This command writes the contents of the new-configs directory on the local flash device to a file named saved. on the TFTP server at 172.20.10.30:

Switch# archive tar /create tftp:172.20.10.30/saved. flash:/new-configs

This example shows how to extract the contents of a file located on the TFTP server at 172.20.10.30:

Switch# archive tar /xtract tftp:/172.20.10.30/saved. flash:/new-configsDisplays the contents of any readable file, including a file on a remote file system.Switch# more flash: /new-configs

archive download-sw /allow-feature-upgrade [/directory] /overwrite /reload tftp:[[//location]/directory]/image-name1.tar [image-name2.tar image-name3.tar image-name4.tar]

archive upload-sw tftp:[[//location]/directory]/image-name.tar


特别提醒:

本文档为自行翻译理解,能力有限不能保证绝对性。

如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。

参考链接:

http://www.cisco.com/c/en/us/td/docs/ios/12_2/configfun/configuration/guide/ffun_c/fcf006.pdf        <<<<主要参考;

https://learningnetwork.cisco.com/docs/DOC-9515 ; <<<<主要参考;

http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst2960x/software/15-0_2_EX/file_management/file_management/flash.html

http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst2960/software/release/12-2_40_se/configuration/guide/scg/swiosfs.pdf



入门指南

使用上面的搜索栏输入关键字、短语或问题,搜索问题的答案。

我们希望您在这里的旅程尽可能顺利,因此这里有一些链接可以帮助您快速熟悉思科社区: