Bird
0
0

What will be the output of this command if the directory test already exists?

medium📝 Command Output Q4 of 15
Linux CLI - File and Directory Operations
What will be the output of this command if the directory test already exists?
mkdir test
ADirectory 'test' is recreated
BError: Directory 'test' already exists
CNo output, command succeeds silently
DDirectory 'test' is deleted and created again
Step-by-Step Solution
Solution:
  1. Step 1: Understand mkdir behavior without -p

    When creating a directory that exists, mkdir returns an error.
  2. Step 2: Check other options

    It does not recreate or delete existing directories silently. Without -p, it errors out.
  3. Final Answer:

    Error: Directory 'test' already exists -> Option B
  4. Quick Check:

    mkdir existing dir = error [OK]
Quick Trick: mkdir errors if directory exists without -p [OK]
Common Mistakes:
MISTAKES
  • Assuming mkdir overwrites existing directories
  • Thinking mkdir deletes old directories
  • Expecting silent success always

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes