rm deletes files. There is no recycle bin and no undo. Learn what -r and -f really do, and why the combination is feared, in a browser terminal where nothing can go wrong.
Updated: 2026-09-04
rm [options] file...
There is no way to get back what rm removes. Files are deleted where they are, not moved to a recycle bin.
The terminal on this page holds files and directories that are safe to destroy.
$ ls
build/ draft.txt empty/ notes.txt README.md
$ rm draft.txt
$ ls
build/ empty/ notes.txt README.md
rm prints nothing on success. Things disappear quietly, which is exactly why you check the target first.
| Option | What it does |
|---|---|
-r | Remove a directory and everything inside it |
-f | Ask nothing, and do not complain about files that do not exist |
-i | Ask before each file |
By default, directories are refused.
$ rm build
rm: cannot remove 'build': Is a directory
$ rm -r build
$ ls
empty/ notes.txt README.md
-r removes everything inside. Do not type it while unsure what the directory contains.
For an empty directory, rmdir also works. It fails when the directory is not empty, which makes it the safer choice when "this should be empty" is an assumption you want checked.
$ rmdir empty
$ ls
notes.txt README.md
| Situation | What to type | Watch out for |
|---|---|---|
| Drop one unwanted file | rm draft.txt | Run ls first |
| Throw away build output | rm -r build | Confirm the path |
| Remove a supposedly empty directory | rmdir empty | Fails if not empty, which is the point |
| Clean up inside a script | rm -f | Keeps going when the file is absent |
rm -f exists for scripts. A missing target is not an error, so cleanup steps do not halt the run.
$ rm missing.txt
rm: cannot remove 'missing.txt': No such file or directory
$ rm -f missing.txt
$ echo $?
0
rm -rf is the dangerous combination.
-r takes everything inside, and -f asks nothing. One mistyped character in the path can remove far more than you meant. Check where you are with pwd and what you are targeting with ls before you press Enter.
Preview wildcards with ls first.
Before rm *.txt, run ls *.txt. You see exactly what would disappear. One character changes the match, so looking first is the reliable habit.
Here, nothing you delete matters.
Everything runs in a virtual file system inside your browser tab and never touches your real files. If you have ever wondered what rm -rf / actually does, this is the place to find out. Reloading the page restores a clean environment.
Terminal for Beginners
Learn basic commands

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the coursermdir / mv / ls