KIM COMPUTER


rm (Remove)

The rm command stands for Remove. It is used to delete files and directories from the filesystem. Unlike some desktop environments, the Linux terminal does not have a "Trash" by default—once a file is removed via rm, it is gone.


1. Basic Usage

rm [options] filename

2. Key Options

Option Name Description
-r recursive Recursive. Removes directories and their contents recursively.
-f force Force. Ignores nonexistent files and never prompts for confirmation.
-i interactive Interactive. Prompts for confirmation before every removal.
-v verbose Verbose. Explains what is being done.
-d dir Removes empty directories.

3. Practical Examples

① Removing a single file

rm archive.zip

② Removing a directory and all its contents

rm -rf backup_folder/

③ Removing files using wildcards

rm *.tmp

④ Safe removal (Asking for permission)

rm -i sensitive_data.key

4. [Warning] Safety Best Practices

  1. Think twice before -rf: Always double-check the path when using rm -rf. A small typo can lead to massive data loss.
  2. Check with ls first: Run ls [pattern] before rm [pattern] to ensure you are targeting the correct files.
  3. Avoid root deletion: Never run rm -rf / or any variant targeting the root directory, as it will destroy your entire operating system.