Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · file management

rm

gone means gone

rm removes the names you give it. With -r it works down through a directory and removes everything inside. Nothing is moved to a trash folder — the space is simply marked free — so the only real protection is reading the command before pressing Enter.

rm does not ask, does not explain and does not keep a copy — you are the confirmation step.

Removes
Files
directories need -r
Undo
None
no trash, no history
Ask first
-i
or -I for one question
Never prompt
-f
also hides errors

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashcoreutils
$ rm -ri build/
1rm: descend into directory 'build/'? y
2rm: remove regular file 'build/app.js'? y
rm: remove regular file 'build/app.css'? y
3rm: remove directory 'build/'? y
$ ls build
4ls: cannot access 'build': No such file or directory
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
-r lets rm go into a directory

Without it rm refuses directories altogether. The question appears because of -i.

2
-i asks about every single file

Slow, but you see exactly what is about to go. -I asks once for the whole operation instead.

3
The directory goes last

It can only be removed once it is empty, so rm works from the inside out.

4
There is nothing to restore

The names are gone and no copy was kept. Recovery now means a backup or a snapshot.

Switches

A switch changes how the command behaves. These are the ones used day to day; man rm lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-r
Recursive: remove a directory and everything inside it. -R is the same.
-f
Force: never ask, and stay silent about files that do not exist.
-i
Interactive: ask before every removal.
-I
Ask once, before removing more than three files or removing recursively.
-d
Remove an empty directory, as rmdir does.
-v
Verbose: print each file as it is removed.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

rm -I *.log

One confirmation before removing more than three files — a sensible default to alias.

rm -rf node_modules

Removes a tree without asking and without complaining. The command to read twice.

rm -- -file.txt

Removes a file whose name starts with a dash.

ls *.tmp && rm *.tmp

List what the pattern matches first; remove only if the list is right.

In cybersecurity

rm is where a small typing mistake becomes a large and permanent one — and deleting a file is still not the same as destroying its contents.

A stray space

"rm -rf /var/www /tmp" and "rm -rf /var/www/ tmp" differ by one space. An empty variable in "rm -rf $DIR/" is worse: it becomes "rm -rf /".

Deleted is not erased

rm frees the space but the data stays on the disk until overwritten. Sensitive files need shred or full-disk encryption.

Never as root by habit

A normal user can only delete their own files. The same command under sudo can delete the system.

Filed under

File management

Read alongside