To delete a folder along with everything inside it — files and subfolders included — use rm with the -r (recursive) flag:
bash
rm -r /path/to/folderReplace /path/to/folder with the actual path you want to delete.
Before you run it:
rm -rdeletes permanently. There's no trash bin, no undo, no confirmation prompt.- Double-check the path. A typo here can wipe out the wrong directory.
- If you get a permissions error, you may need
sudo rm -r /path/to/folder. Use it deliberately —sudobypasses the safety checks that would normally stop you from deleting system-critical files.
Want a safety net? Add -i to get a prompt before each deletion:
bash
rm -ri /path/to/folderIt's slower for large directories, but worth it if you're not 100% sure what's inside the folder.
Changes: tighter intro, pulled the caution notes into a scannable list instead of a dense paragraph, and added the -i tip since it's the natural follow-up any sysadmin would want. Let me know if you want it shorter or in a different tone