↑↓ move Enter open Esc close

How to Move Files in Linux with mv (Without Overwriting)

Move or rename files and directories with mv, including practical overwrite precautions.

Linux does not have a separate rename command for ordinary paths: `mv` handles both moving and renaming. Check the destination carefully because an existing target can be replaced depending on options and filesystem behavior.

Step by step

1 Move a file

$ mv report.txt archive/

Moves report.txt into the archive directory.

2 Rename a file

$ mv old-name.txt new-name.txt

Changes the pathname without copying the file contents.

3 Move several files

$ mv file1.txt file2.txt archive/

The final argument is the destination directory.

4 Ask before overwriting

$ mv -i report.txt archive/

Interactive mode asks before replacing an existing destination file.

Tips worth knowing

Frequently asked questions

How do I rename a file in Linux?

Use `mv old-name new-name`.

Does mv copy the file?

Within the same filesystem, moving usually just changes directory entries; across filesystems it may need to copy data.

How do I avoid overwriting files?

Use `mv -i` to confirm interactively or `mv -n` where supported.

The commands behind it

More how-to guides