Linux Move Directory Command

last updated in Categories

I am new to Linux and command line. How do I move a directory under Linux operating systems?

To move SOURCE directory to a DEST directory use the mv command as follows:

mv source dest
mv /path/to/source /path/to/dest

In this example, move /home/vivek/data/ directory to /nas/home/vivek/archived/ directory:
$ mv /home/vivek/data/ /nas/home/vivek/archived/
OR
$ cd /home/vivek
$ mv data/ /nas/home/vivek/archived/

To get verbose output (explain what is being done), type:
$ mv -v /home/vivek/data/ /nas/home/vivek/archived/

How do I Move Multiple Directories?

Use the following syntax to move dir1 and dir2 to /path/to/dest/ directory:
$ mv -v dir1 dir2 /path/to/dest/
$ ls -l /path/to/dest/

OR use the following syntax:
$ mv -v /home/vivek/dir1/ /home/vivek/dir2/ -t /nas/home/vivek/archived/

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

6 comment

  1. and if for some reasons, you hadn’t the “-v” option enabled at first or would rather be happy with some periodic updates, you can use something like

    watch “lsof -n | grep ‘mv .* /path/to/dest/’ “

  2. thanks a lot
    mv command check the source and dest if!
    source and dest was on a partition action rename
    source and dest was not on a partition action copy

    Have a question? Post it on our forum!