Difficulty: Easy
Correct Answer: rmdir
Explanation:
Introduction / Context:Managing directories from the shell requires specific commands. Unlike removing files, removing directories safely ensures that filesystem structure is not corrupted. There is a specific command in Linux for deleting empty directories.
Given Data / Assumptions:
Concept / Approach:
The rmdir command removes directories, but only if they are empty. For non-empty directories, rm -r is needed. Using the correct command prevents accidental recursive deletions.
Step-by-Step Solution:
Create test: mkdir testdirRemove: rmdir testdirError if not empty: 'Directory not empty'Use rm -r testdir for forced recursive deletion if needed.Verification / Alternative check:
Check with ls before and after removal. rmdir will fail on directories with contents, which is expected behavior.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
rmdir.
Discussion & Comments