Move and rename in Linux with mv command

Share this post to your friends !

This entry is part 2 of 4 in the series Linux commands: Part 4 - Manipulating files and directories

WriteBash - In Linux, to perform the move or rename of a file or directory, we use the mv command. This command performs one of the two features mentioned, depending on usage. In either case, the original filename no longer exists after the operation. mv is used in much the same way as cp command.

Use mv command

To move or rename file or directory “item1” to “item2”.

mv item1 item2
move-and-rename-in-linux-with-mv-command-01 Move and rename in Linux with mv command
mv command

To move one or more items from one directory to another.

mv item... directory

mv command useful options

mv command have many options as the same as cp command:

Some mv options
-bmake a backup of each existing destination file but does not accept an argument
-fdo not prompt before overwriting
-iBefore overwriting an existing file, prompt the user for
confirmation. If this option is not specified, mv will
silently overwrite files.
-uWhen moving files from one directory to another, only
move files that either don’t exist, or are newer than the
existing corresponding files in the destination
-vDisplay informative messages as the move is

To display all options of mv command, execute command below:

mv --help

Some examples of mv command

Read moreListing the contents of a directory

Rename file1 to file2.

mv file1 file2
move-and-rename-in-linux-with-mv-command-02 Move and rename in Linux with mv command
Use mv command to rename file1 to file2

Move file1 and file2 to a directory, you can use for directory as the same way.

mv file1 file2 dir/
move-and-rename-in-linux-with-mv-command-03 Move and rename in Linux with mv command
Use mv command to move files to a directory


This command works very similar to the cp command. The use of the this command should be very careful because it can delete the target file or directory during the use of the command.

Continue reading the series«« Previous part: Copy files and directories with “cp” commandNext part: Create directories with mkdir command »»
If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.