files

mv

Moves or renames files and directories. Within a filesystem it just relinks; across filesystems it copies then deletes.

mv [OPTION]... SOURCE... DEST

Common flags

Flag Purpose
-i Prompt before overwriting DEST
-n Never overwrite an existing file
-f Force overwrite without prompting
-u Move only if SOURCE is newer or DEST is missing
-v Print each move as it happens

Examples

mv old.txt new.txt

Rename a file in place

mv *.log /var/log/archive/

Relocate matching files into a directory

mv -i draft.md posts/

Move safely, prompting on any conflict

mv -n build/ release/

Move without ever overwriting existing entries

Gotcha

There is no built-in undo; renaming over an existing file with -f discards it silently.

Related commands

← All Linux commands · Linux cheat sheet