Files & folders

Linux mv command

Move or rename files and directories.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

mv [OPTION]... SOURCE... DESTINATION

Examples

Move a file and prompt if the destination exists.

mv -i draft.txt ./archive/

Rename a file in the same directory.

mv old-name.txt new-name.txt

Parameters, options and clauses

Option / clauseDescription
-i, --interactivePrompt before overwriting a destination.
-n, --no-clobberDo not overwrite an existing destination.
-f, --forceDo not prompt before overwriting.
-u, --updateMove only when the source is newer or destination is missing.
-t, --target-directory=DIRMove all sources into DIR.
-v, --verboseExplain what is being moved.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory