Before you can remove a directory on Cisco devices the directory must be empty, the below steps will show you how to delete all of the files and folders the directory contains.
Cisco switches often store their IOS in a folder due to them being bundled with HTML files. So this may come in useful when you want to remove your current IOS pre/post an update.
- Connect to you device and enter enable mode.
- Display the contents of your flash using the command dir flash: and make a note of the folder you want to delete
- Issue the command delete /recursive /force flash:/c3750-ipbase-mz.122-52.SE where “c3750-ipbase-mz.122-52.SE” is the name of the folder you want to delete.
- Be carful when using the /force switch as you will not get any “are you sure” messages
- This should also remove the directory, if not once the folder is empty you can use the command rm flash:/c3750-ipbase-mz.122-52.SE to remove the now empty folder
Note: If you switch is part of a stack you may need to do the same on the other members flash (flash1:/ flash2:/ flash3:/ etc)
If you are new to Cisco or would just like to learn more. Pluralsight has some great courses, I have personally been through their CCNA/CCNP content.