🐧 Linux / Shell Scripting
Beginner
How do you move or rename a file in Linux?
Answer
Use the mv command for both moving and renaming. mv oldname newname renames a file within the same directory. mv file /new/path/ moves the file to a new location. mv -i prompts before overwriting existing files. mv -u only moves if the source is newer. Unlike cp, mv does not need a -r flag for directories — it moves them atomically if on the same filesystem. Cross-filesystem moves copy then delete the original.