File System Operations

It also allows for file system operations such as creating and deleting directories and copying, creating, and deleting files to the router’s flash memory and other locations, much like the Windows command prompt. This section provides an overview of file system operations.

File System Display

You can check the available file systems with the show file systems command. The identifiers to identify a file system are defined as follows.

memory spacefile system identifier
RAMsystem:
flash memoryflash:
NVRAMnvram:
USB flash memoryusbflash0:
TFTPtftp:
HTTPhttp:

The file system identifiers and file names allow you to identify data on various memory areas as files.

Changing the Default File System

To change the default directory, use the cd(change directory) command. The default is “flash:”. If you specify a default directory, you can omit the directory from the associated command. You can also check the current default directory with the pwd command.

Viewing a list of files

You can use the dir command to display a list of files in a directory.

#dir [<filesystem:>]

R1#dir
Directory of nvram:/

  123  -rw-        1401                      startup-config
  124  ----           0                      private-config

129016 bytes total (127563 bytes free)

Creating and deleting directories

To create the directory, use the mkdir command in privileged EXEC mode.

#mkdir <directory-name>

Center#mkdir temp
Create directory filename [temp]?
Created dir flash:temp
Center#dir
Directory of flash:/

    1  -rw-    30112780  Sep 13 2012 06:43:22 +00:00  c890-universalk9-mz.150-1.M3.bin
    2  -rw-         840   Aug 6 2014 01:57:46 +00:00  vlan.dat
    3  drw-           0  Jun 26 2019 01:35:40 +00:00  temp

252997632 bytes total (222875648 bytes free)

You can also use the delete command to delete a directory.

#delete [/force] [/recursive] <directory-name>

The /force option omits the prompt to confirm the deletion. The /recursive option deletes all files and subdirectories in the directory.

You can also use the rmdir command to remove directories.

Copying files

The copy command allows you to copy files.

#copy <source-filename> <destination-filename>

The copy command not only copies running-config to startup-config, but also allows you to copy the various files managed by IOS.

Creating the tar file

To create a tarball of files in a directory, you can use the following command.

archive tar /create <destination-filename> <source-directory-name>

<destination-filename> : The name of the tar file to be created
<source-directory-name> : Directory name to put in the tar file

To check the list of files in the tar file, you can use the following command.

archive tar /table <filename>

<filename> : tar file name

Here’s an example of how the files in the “configs” directory are grouped together in the “configs.tar” file.

Center#dir configs
Directory of flash:/configs/

    6  -rw-        1241  Jun 26 2019 04:56:42 +00:00  config1.cfg
    7  -rw-        1241  Jun 26 2019 04:57:20 +00:00  config2.cfg

252997632 bytes total (222863360 bytes free)
Center#archive tar /create configs.tar flash:/configs
archiving config1.cfg (1241 bytes)
archiving config2.cfg (1241 bytes)
Center#dir
Directory of flash:/

    1  -rw-    30112780  Sep 13 2012 06:43:22 +00:00  c890-universalk9-mz.150-1.M3.bin
    2  -rw-         840   Aug 6 2014 01:57:46 +00:00  vlan.dat
    3  drw-           0  Jun 26 2019 01:38:26 +00:00  temp
    5  drw-           0  Jun 26 2019 04:56:18 +00:00  configs
    8  -rw-        4096  Jun 26 2019 05:47:02 +00:00  configs.tar


Center#archive tar /table configs.tar
config1.cfg (1241 bytes)
config2.cfg (1241 bytes)

Display the contents of the file

You can use the more command to display the contents of the readable files on the console.

#more <filename>

<filename> : File name to be displayed

The following is an example showing the contents of “config1.cfg” in the “configs” directory.

Center#more flash:/configs/config1.cfg
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Center
!
boot-start-marker
boot-end-marker
-- omitted -- 

Cisco Basic