Linux mv Command Tutorial with Examples To Move Files

Linux mv command is used to move or rename files. We generally provide the source and destination files and directories to mv command.

Syntax

mv [OPTION]... SOURCE... DIRECTORY

Move

The regular usage of mv command is moving files or directories. We will provide source files or directory and destination file or directory. In this example we will move or rename directory named backup into live .

$ mv backup live

Force

If there is files and folders in  the destination the mv command will stop moving. We can force move operation with -f option.

$ mv -f backup live

Ask Before Overwrite

We can prompt before overwriting destination file. We will use -i option for this. In order to accept overwrite we should answer with y or Y .

$ mv -i backup live

Verbose

While moving files we may need to list all moved files. We call this verbose mode. This will list moved files line by line with -v option like below.

$ mv -v backup live

Leave a Comment