Bird
0
0

Why does mkdir -p not return an error if the directory already exists?

hard📝 Conceptual Q10 of 15
Linux CLI - File and Directory Operations
Why does mkdir -p not return an error if the directory already exists?
ABecause it creates a backup of existing directories before creation
BBecause it ignores existing directories and creates only missing ones
CBecause it prompts the user to overwrite existing directories
DBecause it deletes existing directories before creating new ones
Step-by-Step Solution
Solution:
  1. Step 1: Understand mkdir -p behavior

    The -p option allows mkdir to skip creating directories that already exist without error.
  2. Step 2: Analyze other options

    It does not delete, prompt, or backup existing directories.
  3. Final Answer:

    Because it ignores existing directories and creates only missing ones -> Option B
  4. Quick Check:

    mkdir -p skips existing dirs without error [OK]
Quick Trick: mkdir -p safely creates dirs, ignoring existing ones [OK]
Common Mistakes:
  • Thinking it deletes existing directories
  • Expecting prompts or backups
  • Assuming error on existing dirs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes