Difficulty: Easy
Correct Answer: rm
Explanation:
Introduction / Context:
Removing files safely and correctly is a fundamental shell skill. The standard POSIX command for deleting files is short and powerful, supporting interactive prompts, recursive removal for directories, and forceful deletion when required. Knowing the right command prevents confusion with DOS/Windows terminology.
Given Data / Assumptions:
Concept / Approach:
The command 'rm' removes directory entries for files. Common switches include '-i' for interactive confirmation, '-f' to force and ignore nonexistent files, and '-r' (or '-R') to recurse into directories. Deletion is immediate; recovery relies on backups or snapshots, so caution is advised, especially with wildcards and elevated privileges.
Step-by-Step Solution:
Verification / Alternative check:
Run 'ls' after the command to confirm the files are gone. For critical data, simulate first with 'echo rm ...' to ensure globbing expands as expected before committing the real removal.
Why Other Options Are Wrong:
Common Pitfalls:
Using 'rm -rf /' style destructive commands, forgetting that 'rm' does not use a trash can, and not quoting filenames with spaces or special characters.
Final Answer:
rm
Discussion & Comments