Removing Files & Folders
Concept & Overview
When you clean up your physical desk, you might throw old papers into a recycling bin where you can retrieve them if you made a mistake. In Linux, there is no safety net—when you delete something from the terminal, it is gone forever!
- The rm command deletes files.
- Because folders can contain other files, rm won't delete a folder by default. You must add the -r (recursive) flag to tell Linux to dive in and delete the folder along with everything inside it.
Why this matters: If you run rm downloads without -r when downloads is a folder, you'll get: rm: cannot remove 'downloads': Is a directory. The -r flag tells Linux to recursively delete the folder and everything inside it.
downloads folder and all its contents by running rm -r downloads.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
rm -r downloads | Delete folder recursively |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Use the "rm" command with -r flag
- ○Directory /home/learner/downloads is deleted
Ready to complete Quest 21?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.