Bird
0
0

You try to delete a directory named docs using rm docs but get the error: rm: cannot remove 'docs': Is a directory. What is the correct way to remove it?

medium📝 Debug Q6 of 15
Linux CLI - File and Directory Operations
You try to delete a directory named docs using rm docs but get the error: rm: cannot remove 'docs': Is a directory. What is the correct way to remove it?
AUse <code>rm -r docs</code> to remove the directory and its contents
BUse <code>rm -f docs</code> to force delete the directory
CUse <code>rm docs/*</code> to delete files inside only
DUse <code>rm --dir docs</code> to delete the directory
Step-by-Step Solution
Solution:
  1. Step 1: Understand the error

    The error indicates rm cannot delete directories without recursive option.
  2. Step 2: Use recursive deletion

    rm -r deletes directories and their contents recursively.
  3. Step 3: Evaluate other options

    -f forces deletion but does not allow directory removal alone; rm docs/* deletes files inside but not the directory; --dir is not a valid option.
  4. Final Answer:

    Use rm -r docs -> Option A
  5. Quick Check:

    Directories require -r to remove [OK]
Quick Trick: Use rm -r to delete directories and contents [OK]
Common Mistakes:
  • Using rm without -r on directories
  • Assuming -f deletes directories forcibly
  • Trying invalid options like --dir

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes