Linux Move Directory Command

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:

ADVERTISEMENTS

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/

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
6 comments… add one
  • sylvainulg Apr 3, 2012 @ 12:05

    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/’ “

  • Ilan Ben-Shmuel Apr 24, 2013 @ 0:44

    Also openjdk-6 libraries works for me

  • Tshepo Mar 17, 2015 @ 20:04

    Bash: “No such file or directory”

  • aref ghobadi Aug 18, 2015 @ 11:01

    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

  • Dileep Thomas Nov 17, 2016 @ 4:31

    Thanks for the Solution. It worked for me. :)

  • Oguzhan Aug 2, 2017 @ 5:35

    Thank you man

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.