Linux Commands Helper
💬 Your AI-powered Linux assistant
mv Command - Move or Rename Files
The mv command is used to move files or directories, or rename files or directories.
Syntax
mv [options] source target
Common Options
-i
: Interactive mode. Prompt before overwriting.-f
: Force move without prompting.-u
: Move only when the source is newer or the target does not exist.-v
: Verbose mode. Show details of the move.
Examples
mv file1.txt /home/user/docs/
Move file1.txt to the /home/user/docs/ directory.
mv oldname.txt newname.txt
Rename oldname.txt to newname.txt.
mv -i file1.txt /home/user/docs/
Move file1.txt to /home/user/docs/ and prompt if the target exists.
Notes
- The mv command does not modify file content, only the location or name.
- If the source and target are on the same filesystem, only the directory entry changes (very efficient).
- If moving across filesystems, mv copies and then deletes the source.
Related Linux Commands:
- source - Read and execute commands from a file
- read - Read a line from standard input
- visudo - Edit the sudoers file
- hexdump - Display file contents in various formats
- hwclock - Show and set hardware clock
- mysqlbinlog - View MySQL binary logs
- zless - View compressed files
- xwininfo - Get information about windows
- umask - Manage default permissions
- patch - Apply patches to files