# Deleting: rm and the missing trash can

Course: Terminal Basics — https://zero2vibecode.com/learn/terminal-basics
Canonical URL: https://zero2vibecode.com/learn/terminal-basics/2-4-deleting-safely

`rm` deletes a file and `rm -r` deletes a folder. Neither of them uses a trash can — what you delete here is gone.

Time to be blunt about this one.

## There is no trash can

When you delete a file in a graphical file manager, it goes to the trash. You can change your mind.

The terminal has no such thing. `rm` removes the file, and there is nowhere to look for it afterwards.

```
rm draft.txt
```

Silent, instant, permanent. No confirmation, no "are you sure", no undo.

This is not a scare tactic and it is not a simulator quirk. On a real machine, a file removed with `rm` is genuinely unrecoverable by any normal means. Professionals lose work to this every year.

## Deleting a folder: -r

Point `rm` at a folder and it refuses:

```
rm temp
rm: cannot remove 'temp': Is a directory
```

That refusal is deliberate. A folder can hold hundreds of files, and deleting it deletes all of them. So `rm` makes you ask again, explicitly, with `-r` for *recursive*:

```
rm -r temp
```

Now `temp` and everything inside it is gone, at every depth.

## The flag combination to slow down for

`-f` stands for *force*. It tells `rm` to stop objecting — including about files that do not exist, and about things it would normally hesitate over.

Put them together and you get `rm -rf`, which means: delete this folder and everything in it, recursively, and do not complain about anything.

It is a legitimate command. Cleaning a build folder is exactly what it is for. What makes it dangerous is that it removes every guard rail at the same moment you are handing it a path — and if that path is wrong, nothing will stop you.

The infamous one is `rm -rf /`, which aims the whole thing at the root of the disk. This simulator will refuse it and tell you off. Your laptop will not be as friendly.

## The habit that actually protects you

Not fear. A two-second routine:

1. `ls` the folder, so you can see what you are about to delete.
2. Read the path in your `rm` command out loud, once.
3. Then run it.

Most `rm` accidents are not typos in the command — they are the right command aimed at the wrong folder, run by someone who did not check where they were standing. `pwd` and `ls` are the cure.

On a real machine there is a better default: put things in a `trash` folder of your own with `mv`, and empty it when you are sure. `mv` is reversible; `rm` is not.

## Try it

The `scratch` folder has one file to keep, one to delete, and a whole folder of rubbish.

1. `ls` — look before you delete.
2. `rm draft.txt` — remove the file.
3. `rm -r temp` — remove the folder and its contents.
4. `ls` — confirm that `old-notes.txt` is still there.

Step 4 matters as much as steps 2 and 3. Deleting the right things is only half the job; the other half is confirming you did not take anything else with them.
