commands

mv — move or rename files

Moves an entry or renames it. Existing directory destinations normally receive the source basename. Across filesystems a move can copy then remove the source, so atomic rename is not guaranteed. Examples assume a fresh chapter files lab.

Formal Syntax & Structure

linux syntaxlinux
mv [OPTION]... SOURCE DEST

Parameters & Attributes

NameTypeDescription
-ioptionPrompt before overwrite
-noptionSkip existing destinations; status behavior depends on version
SOURCEoperandObject to move
DESToperandDestination path

Return Value

filesystem change and exit status

GNU mv returns 0 on success and nonzero on failure. Declining an interactive overwrite returned 1 and preserved both source and destination in the tested GNU version; verify both paths, particularly after a cross-filesystem move.

Working Example

Example Snippetlinux
mv -i notes/hello.txt archive/saved.txt
Linux Reference