If you simply want to return a Cisco IOS-based router or switch back to its factory defaults or remove the current running configuration file, whether you’re a network administrator, a network engineer, or studying for the CCNA exam, then you need to know how to erase configuration files on a Cisco router or switch.
And this tutorial will help you figure out the best Cisco IOS command to erase the startup and running configuration files.
What is The Cisco IOS Command Used to Erase The startup-config File on a Router or Switch?
You can clear the startup-config file using the erase startup-config command, or the write erase command. When you reload the router/switch, it boots up without an initial configuration and you must configure it from the beginning.
These two commands affect the startup-config file only from NVRAM, while the erase /all nvram: command and the erase nvram: command clear the contents of all configuration files in NVRAM including the startup-config file.
This example illustrates how to delete the startup configuration file’s content using the erase startup-config command.
R1# erase startup-config Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] ! press Enter key [OK] Erase of nvram: complete R1#
In this example, we use the erase nvram: command to clear the content of NVRAM.
R1# erase nvram: Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] ! press Enter key [OK] Erase of nvram: complete R1#
If the startup-config file is configured to be stored on a Class A file system platform, the erase nvram: command marks the corresponding file as deleted.
The following example shows how to return the router to a factory default configuration using the write erase command.
R1# write erase Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] ! press Enter key [OK] Erase of nvram: complete R1#
Note that the write erase command is obsolete, and Cisco has replaced it with the erase startup-config command.
The following example shows how to reset the startup configuration and delete all files in NVRAM except the startup-config file and the private-config file.
R1# erase /all nvram: Erasing the nvram filesystem will remove all files! Continue? [confirm] ! press Enter key [OK] Erase of nvram: complete R1#
The erase /all nvram: command clears the content of all configuration files in NVRAM including the startup configuration file. The command removes non-configuration files stored in NVRAM, as shown in the output of the dir nvram: command.
R1# dir nvram: Directory of nvram:/ 254 -rw- 0 startup-config 255 ---- 0 private-config 262144 bytes total (262092 bytes free)
Moreover, when you issue this Cisco IOS command, you cannot recover the files in NVRAM.
What is The Cisco IOS Command Used to Erase The running-config File on a Router or Switch?
Clearing the running configuration means resetting its content to match the startup configuration. It does not mean you can remove all commands from it, thus making it empty.
To erase the running configuration file, issue the copy startup-config running-config command in enable mode, as shown in this example.
R1# copy startup-config running-config Destination filename [running-config]? ! press Enter key 1203 bytes copied in 2.220 secs (542 bytes/sec) R1#
You may think of creating an empty file in flash memory, and then copying it into the running configuration file using the copy command. However, that won’t work, and Cisco IOS would replace the running-config file’s content with the one of the startup-config file.
To create an empty file in flash memory, use the following script.
R2# tclsh R2(tcl)# puts [open "flash:config.txt" w+] { +>(tcl)# } R2(tcl)# tclquit
The following example copies the config.txt file into the running-config file.
R1# copy flash:-cofig.txt running-config Destination filename [running-config]? ! press Enter key 2 bytes copied in 0.020 secs (100 bytes/sec) R1#
Related Lessons to How To Erase Configuration Files on a Cisco Router or Switch
- How To Backup Cisco Switch/Router Images Using TFTP Server
- How To Backup/Restore Cisco Switch/Router Configuration Files Using SCP Server
- How To Backup Cisco Switch/Router Images Using FTP Server
- Memory Types Used in a Cisco Router
- How To Reset a Cisco Switch to Factory Defaults
- How to Reset a Cisco Router to Factory Defaults
- How To Backup and Restore Cisco Switch/Router IOS Images Using SCP Server
- How To Backup and Restore Cisco Switch/Router Configuration Files Using FTP
- How To Backup and Restore Cisco Switch/Router Configuration Files Using TFTP Server
- How To Erase Configuration Files on a Cisco Router or Switch
- Cisco IOS More Command
- How To Upgrade Cisco IOS via FTP/TFTP/USB Drive or Console Cable
Conclusion
I hope this blog post helps you learn something.
Now I’d like to turn it over to you:
What did you like about this tutorial?
Or maybe you have an excellent idea that you think I need to add.
Either way, let me know by leaving a comment below right now.