5 ways to use the move command in Linux

User Avatar
👤 admin
🔴 Admin
✍️ The most important thing in the world is to not be alone.
⏳ Last active: 23 Sep 2025 at 14:41
📅 Created: 02 May 2021 at 08:03
👀 Viewed: 103 times
✉️ Send Email

In this article, you will learn 5 common uses of ```

mv

 command in Linux. The 

mv


1. Moving files using mv command

If you need to move file abc.txt for example in another directory, lets say /home/sonik/Desktop/ here is how it's done:

mv abc.txt /home/sonik/Desktop/


2. Take a backup before overwriting

Using the<strong> -```

b
```</strong> option, you can take backup of destination file before overwriting the existing file.

mv -bv *.txt ./home/sonik/Desktop/


3. Renaming files and directories 
Renaming files or directories works just as same as moving a file, except you have to be in the same location.

How to rename file.txt to filenew.txt in same the location.

mv file.txt filenew.txt

How to rename a directory

mv dir dirnew


4. Don't override any existing files

The following command merges one folder to another, but doesn't override any existing files

mv -n dir1/* ./home/dir2

only update with the new file

mv -u dir1/* ./home/dir2


5. Move the files from parent directory to one of the child

You can move all the files from parent directory to the child directory with the following command:

cd parent

mv !(child1|child2) child1



We hope you enjoyed this <a href="https://lateweb.info/category/linux/">article</a>. if that is so please rate this page with the stars bellow and subscribe to our <a href="https://www.youtube.com/channel/UCh7Q9uaAt5-Z2lCZXX3OsvQ">YouTube channel</a>.
If you want to comment: Login or Register