Bird
0
0

A user runs rm -r folder1 but accidentally deletes important files. How can this be prevented?

medium📝 Debug Q7 of 15
Linux CLI - File and Directory Operations
A user runs rm -r folder1 but accidentally deletes important files. How can this be prevented?
AUse <code>rm folder1</code> without -r
BUse <code>rm -ri folder1</code> to prompt before each deletion
CUse <code>rmdir folder1</code> always
DUse <code>rm -f folder1</code> to force deletion
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to add safety to rm -r

    The -i option prompts user before deleting each file or directory.
  2. Step 2: Apply to prevent accidental deletion

    Using rm -ri folder1 asks for confirmation, reducing accidental deletes.
  3. Final Answer:

    Use rm -ri folder1 to prompt before each deletion -> Option B
  4. Quick Check:

    Interactive mode (-i) prevents accidental deletes [OK]
Quick Trick: Add -i to rm -r for confirmation prompts [OK]
Common Mistakes:
MISTAKES
  • Using rm without -r on directories
  • Using rmdir which only removes empty directories
  • Using -f which forces deletion without prompts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes