I have a Cisco router, and I want to remove a few lines from startup-config. How could I do it? Do I need to copy it over to a PC, edit it there, then copy it back, or can I do it through the serial console somehow?
Edit: Karl Billington's method is superior and should be used when possible
The other (extremely painful) way is:
Setup a console connection if you don't already have one. The rest of the steps below are over the console connection
Reboot the switch, stop it at the rommon/bootloader (usually Control-C or break)
Configure the rommon/bootloader to ignore the startup Boot the IOS. It should come up with a default config after ignoring the startup-config
show startup-config. This will print the entire startup-config, including the undesirable lines that you want to remove.
Now do a
conf termand start pasting the output of
show startup-config, excluding the undesirable lines that you want to exclude
Issue the command
wr mem. This will save your edited config.
Reboot. This time configure the rommon/bootloader to not ignore the startup-config
As you can see this is extremely messy, and is error-prone especially if your config is large. But if the real solution (editing it off-box and then copying it to the device) won't work for whatever reason, and you're in a "desperate times call for desperate measures" situation, you can give this a shot.
Yes, only real way is to copy the startup-config file to a PC and edit on there, then copy back. Of course the commands will not take effect until the next reload and you will have to be careful you don't corrupt the config in any way. Make sure you use a proper text editor like Notepad++ and not a word processor when you edit to make sure you don't insert any odd character codes.