Linux Move Directory Command

mv command is one of the most classic and useful commands for Linux users. You will use it in your day to day tasks as a system administrator or normal Linux / Unix user.

mv command is not only useful to move directories, but also to rename directories and files inside Linux and Unix operating systems. It is one of the most basic Linux commands, and on this tutorial I will show you how to move one single directory on Linux, and move multiple directories to a new destination path.

How can I move a directory in Linux operating system?

In order to move a source directory to a destination directory, you can use the mv command as you see below:

mv origin destiny
mv /origin/path /destiny/path/

In the previous example, we just moved one file to a new destination.

In this example, we will move /home/nixcp/info/ directory to /var/archives/ directory:

mv /home/nixcp/info /var/archives/

or we can simply use:

cd /home/nixcp/
mv info /var/archives/

If you want to get a verbose output of this mv command, you can always add -v parameter, for example:

mv /home/nixcp/info /var/archives/ -v

Move multiple directories in Linux

In order to move multiple directories in Linux, you can use this sintax:

mv directory1 directory2 /destination/path/ -v

After that, run a ls command to see if the move was done ok:

ls -l /destination/path/

You can also use the following mv command syntax:

mv -v /home/nixcp/directory1/ /home/nixcp/directory2/ -t /var/archives/

Here we used -t option also, which will move all SOURCE arguments into destination DIRECTORY.

Now you know how to move directories on Linux systems. This is also useful for Mac OS, all kind of BSD systems and Unix like.

Need more information about how to use mv command to move directories on Linux? Check out the man page:

man mv


mv --help

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *