Linux and Unix mv command

Quick links

About mv
Syntax
Examples
Related commands
Linux and Unix main page

About mv

Renames a file or moves it from one directory to another directory.

Syntax

mv [-f] [-i] oldname newname

-fmv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal.
-iPrompts before overwriting another file.
oldnameThe oldname of the file renaming.
newnameThe newname of the file renaming.
filenameThe name of the file you want to move directory - The directory of were you want the file to go.

Examples

mv myfile.txt newdirectory/

Moves the file myfile.txt to the directory newdirectory.

mv myfile.txt ../

Moves the file myfile.txt back one directory (if available).

mv computer\ hope.txt computer_hope.txt

Moves (renames) the file "computer hope.txt" to computer_hope.txt. When working with a file or directory with a space you must escape that space with a backslash or surround the filename or directory with quotes.

Related commands

copy
cp

cpio
ln
rm
setfacl