Bird
0
0

Which command removes an empty directory named temp but fails if it is not empty?

easy📝 Conceptual Q2 of 15
Linux CLI - File and Directory Operations
Which command removes an empty directory named temp but fails if it is not empty?
Armdir temp
Brm temp
Crm -r temp
Drm -f temp
Step-by-Step Solution
Solution:
  1. Step 1: Identify command for removing empty directories

    The rmdir command removes empty directories only.
  2. Step 2: Compare with other options

    rm -r temp removes directories recursively even if not empty. rm temp removes files, not directories. rm -f temp forces file removal, not directories.
  3. Final Answer:

    rmdir temp -> Option A
  4. Quick Check:

    Empty directory removal = rmdir [OK]
Quick Trick: Use rmdir for empty directories, rm -r for non-empty [OK]
Common Mistakes:
MISTAKES
  • Using rm without -r on directories
  • Using rm -f which ignores directories
  • Confusing rmdir with rm -r

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes