Linux for Developers Course
Linux for Developers
/
Beginner

rm

Definition

Remove. The command used to permanently delete files or directories.

Explain Like I'm New

The delete button, but with no recycle bin. Once a file is gone, it is gone forever.

Real World Example

You want to delete an old log file. You type `rm old.log`. The file is permanently destroyed.

Common Use Cases

  • •Cleaning up disk space
  • •Deleting unwanted code

Crucial Command Flags

Flag / OptionDescription
-r / -RRecursive. Remove directories and their contents.
-fForce. Ignore nonexistent files, never prompt.
-iInteractive. Prompt before every removal.

Interview Questions

basic

  • If you `rm` a file, can you easily recover it from the Trash/Recycle Bin?

intermediate

  • What does the infamous command `rm -rf /` do?

Flash Cards

Question

Recover from trash?

Click to reveal answer
Answer

No. The `rm` command bypasses the trash entirely and permanently unlinks the file from the disk.

Question

What does rm -rf / do?

Click to reveal answer
Answer

It is the self-destruct sequence. `-r` means recursively delete all folders. `-f` means force (don't ask for confirmation). `/` is the root of the computer. It literally deletes the entire operating system and all your data.