Difficulty: Easy
Correct Answer: mv
Explanation:
Introduction / Context:
File management in Unix relies on a small set of powerful commands. Renaming is not a distinct operation; it is handled by the same command that moves files between paths. Recognizing the correct tool is essential for scripting and daily use.
Given Data / Assumptions:
Concept / Approach:
The mv
command moves files and directories. If the destination is within the same directory but with a different name, the effect is a rename. While some distributions ship a rename
utility, its syntax and availability vary and it handles pattern-based mass renames; mv
is the portable tool. remove
is not a standard command; file deletion uses rm
. ren
is a DOS/Windows alias, not standard on Unix.
Step-by-Step Solution:
mv
.Rename example: mv oldname.txt newname.txt
.Move and rename example: mv oldname.txt docs/newname.txt
.Verify with ls
that the new name/path exists.
Verification / Alternative check:
Consult man mv
. You will see it supports moving and renaming. Experiment in a test directory to confirm behavior.
Why Other Options Are Wrong:
rm
to delete, not rename).mv
is correct.
Common Pitfalls:
Overwriting existing files without -i
; renaming across filesystems may copy then delete; remembering that permissions may restrict renames in directories without write/execute rights.
Final Answer:
mv
Discussion & Comments