Bird
0
0

What will happen if you run rm -r nonexistdir where nonexistdir does not exist?

medium📝 Command Output Q5 of 15
Linux CLI - File and Directory Operations
What will happen if you run rm -r nonexistdir where nonexistdir does not exist?
AIt will silently do nothing
BIt will show an error: 'No such file or directory'
CIt will create the directory 'nonexistdir'
DIt will remove the current directory
Step-by-Step Solution
Solution:
  1. Step 1: Understand rm behavior on non-existing targets

    When rm tries to remove a non-existing file or directory, it shows an error.
  2. Step 2: Apply to nonexistdir

    Since nonexistdir does not exist, rm -r nonexistdir outputs an error message.
  3. Final Answer:

    It will show an error: 'No such file or directory' -> Option B
  4. Quick Check:

    rm error on missing target = 'No such file or directory' [OK]
Quick Trick: rm shows error if target does not exist [OK]
Common Mistakes:
  • Expecting silent success on missing directory
  • Thinking rm creates missing directories
  • Confusing error with permission denied

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes