File Commands and their Usage in Cisco IOS

Similar to a Windows or Linux operating systems, the Cisco IOS is rooted in Unix and has its own list of commands to manipulate files. These commands are very similar to DOS/Windows commands.

Files could be your IOS router operating system executable, configuration file(s), or other type of IOS file. Knowing these file commands is a critical requirement for any one using a Cisco product.

Below is a top list of Cisco IOS file management commands you must know. (Note that I am in privileged mode for most of the examples)

#1 dir

This shows a directory list of files on a filesystem. To see the options, type ‘dir ?’:

Cell_Router#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

You can think of each of these filesystems almost like disk drives in DOS, where you have to put a colon after the name. So, the nvram is called nvram:. The default is to show a directory of the router’s flash as your default current directory is flash:

Cell_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)

Every router will have at least flash memory and nvram (non-volatile random access memory).

#2 cd

Change directory: Use cd to change your current directory to a different device or subdirectory on that device.

In the following example, when I change my directory to the nvram: filesystem and do a dir, I get a list of nvram. I could also cd to a subdirectory after I have created a directory with mkdir.

Cell_Router#cd nvram:
Directory of nvram:/

126 -rw- 2143 <no date> startup-config
127 —- 5 <no date> private-config
128 -rw- 2143 <no date> underlying-config
1 —- 49 <no date> persistent-data
2 -rw- 0 <no date> ifIndex-table
131072 bytes total (116584 bytes free)

#3 copy

This is used to copy the IOS or a config file from and to somewhere. You would use this to copy the router’s configuration off the router to a TFTP server or just make a local backup of it on the router. You would also use the copy command to upgrade the router with a new IOS from a TFTP server.

The example below is making a local backup of the router’s running configuration:

Cell_Router#copy running-config andys-backup-before-upgrade
Destination filename [andys-backup-before-upgrade]?
2181 bytes copied in 3.052 secs (715 bytes/sec)

#4 delete and rm

Very simply, you will use delete to delete files and rm to remove folders/directories. Here, we use delete to delete the backup of my config that we just created:

Cell_Router#delete andys-backup-before-upgrade
Delete filename [andys-backup-before-upgrade]?
Delete flash:/andys-backup-before-upgrade? [confirm]

#5 show flash

This is used to show the files in your flash. The command show flash is similar to dir flash: but it provides a little more information on the size and type of flash memory in your router.

Cell_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)

#6 erase and format

It can be a bit confusing why you would erase one type of filesystem, but format another. What you really need to know is that you format flash devices and erase nvram. There are other types of filesystems, and you may erase or format them, depending on their type. The erase command is most used when you want to wipe out the router’s configuration and start with a default configuration. This is done with erase startup-configuration.

Cell_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

Cell_Router# format ?
flash: Filesystem to be formatted


#7 more

This shows a text / configuration file. Let’s say that you want to view a backup configuration file that you created. Just use the more command to view it:

Cell_Router# more my-backup-config
version 12.4
parser config cache interface
parser config interface
{config truncated}

#8 verify

This is used to verify the checksum or compute a MD5 signature for a file.

Cell_Router#verify flash:c870-advipservicesk9-mz.124-15.T5.bin
Verifying file integrity of flash:c870-advipservicesk9-mz.124-15.T5.bin…….{truncated}………… 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).

#9 mkdir

Just like in DOS, you use mkdir to create a directory/folder. I would do this to perhaps create an archive folder for backup configurations or old IOS files.

Cell_Router# mkdir backup-configs
Create directory filename [backup-configs]?
Created dir flash:backup-configs

#10 fsck

FAT filesystem check is typically used to check your flash filesystem integrity. You may do this if you have experienced some corruption of your IOS files in flash.

Cell_Router# fsck
Fsck operation may take a while. Continue? [confirm]
Fsck of flash: complete

While there are so many reasons to use file system commands like these, if we had to select three of the most practical uses for some of the commands listed above, here is the list:

  • Navigating the Cisco IOS filesystems — knowing what configuration files and what IOS files are on the router, perhaps before performing an upgrade.
  • Back up your configuration to the local router or off to a TFTP server, again, perhaps before a backup
  • Performing an upgrade of the Cisco IOS by copying the IOS from a TFTP server to the router.

It’s very important to understand IOS file management commands, what those commands are, and how you can use them in the real world. You don’t want to be stumbling to restore your IOS when the primary IOS is corrupt.

We hope this helps.

Leave a Comment

Contact Us Here

Please verify.
Validation complete :)
Validation failed :(
Your contact request has been received. We usually respond within an hour, but please be patient. We will get back to you very soon.
Scroll to Top