Bird
0
0

What happens when you run rm -rf /tmp/testdir if /tmp/testdir contains files?

medium📝 Command Output Q5 of 15
Linux CLI - File and Directory Operations
What happens when you run rm -rf /tmp/testdir if /tmp/testdir contains files?
APrompts before deleting each file
BFails because directory is not empty
CDeletes the directory and all its contents without prompts
DDeletes only empty directories inside
Step-by-Step Solution
Solution:
  1. Step 1: Understand -rf options

    -r means recursive, -f means force (no prompts). Effect on directory with files: It deletes the directory and all files inside silently.
  2. Final Answer:

    Deletes the directory and all its contents without prompts -> Option C
  3. Quick Check:

    rm -rf force deletes recursively [OK]
Quick Trick: Use -rf to force delete folders with files silently [OK]
Common Mistakes:
  • Expecting prompts with -f
  • Thinking it fails on non-empty dirs
  • Confusing -f with -i

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes