Linux Commands | File Management | mv Move Files/Directories

mv Command

The mv command moves files or directories, or renames them. mv is short for “move”.

  1. If no file with the same name exists at the destination, the file or directory is moved.
  2. If a file with the same name exists at the destination, the target can be renamed.

Syntax

mv [source file path/name] [destination path/name]

mv Command Examples

Example 1

Move the test1 file to /backup.

mv /test/test1 /backup

Example 2

Rename the passwd file to pw.

mv /backup/passwd /backup/pw