Move files and folders

mv is a command-line program for moving and renaming files and folders.

In this tutorial we will be using mv to move files and folders. There is a companion tutorial called [[Rename Files and Folders]].

Note: The terms "folder" and "directory" mean the same thing--they can be used interchangeably.


mv [source] [target]
  • [source] -- Filepath of the file or folder you want to move.
  • [target] -- Filepath for where your [source] should be moved.

Example #1 -- Move file

mv /root/logo.png /var/www/ 

New Filepath: /var/www/logo.png

Example #2 -- Move folder

The folder itself will be placed in a new location.

New Filepath: /var/www/foo/

Example #3-- Move folder contents

All the files inside "foo" will be placed in "www" while the "foo" directory remains inside the root directory.

mv /root/foo/* /var/www/ 

Remember: When the asterisk "*" is used in a filepath, it is considered a "wildcard"--meaning it represents "anything." All files and folders within a folder will be considered a match.