Linux for Developers
/Beginner
mv
Definition
Move. The command used to move files or directories from one place to another. It is also the primary command used to rename files.
Explain Like I'm New
Cut and Paste. It takes the file, puts it somewhere else, and deletes the original. If you move a file into the exact same folder but with a new name, it is a 'Rename'.
Real World Example
You misspell a file name. You type `mv imgae.jpg image.jpg`. The file is instantly renamed.
Common Use Cases
- •Organizing files
- •Renaming files
Crucial Command Flags
| Flag / Option | Description |
|---|---|
| -i | Interactive. Prompt before overwriting an existing file. |
| -f | Force. Overwrite existing files without prompting. |
| -v | Verbose. Explain what is being done. |
Interview Questions
basic
- Does Linux have a dedicated `rename` command, or do you mostly use `mv` to rename things?
intermediate
- If you `mv` a 100GB file from one folder to another folder on the EXACT SAME hard drive, why does it happen instantly (in milliseconds)?