{"id":16955,"date":"2022-04-26T09:36:25","date_gmt":"2022-04-26T09:36:25","guid":{"rendered":"https:\/\/linuxways.net\/?p=16955"},"modified":"2022-04-26T10:54:21","modified_gmt":"2022-04-26T10:54:21","slug":"how-to-move-a-directory-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-move-a-directory-in-linux\/","title":{"rendered":"How to Move a Directory in Linux"},"content":{"rendered":"<p>On Linux, moving a directory is a common activity that every user will have to do at some point. This can be done using any installed desktop environment or the mv command from the command line.<\/p>\n<p>While this is a rather straightforward function, there are a few things to bear in mind. We&#8217;ll go over various examples of relocating a directory on Linux in this article. To learn more about the mv command and GUI process, you can look up this article.<\/p>\n<p>This article will teach you how to:<\/p>\n<p>How to move a directory using a Graphical User Interface (GUI)<\/p>\n<p>How to move a directory using the Command Line Method<\/p>\n<h2>Method 1: Move a Directory Using a Graphical User Interface (GUI)<\/h2>\n<p>The method for moving a directory on Linux via the graphical interface varies slightly based on the distribution and desktop environment you&#8217;ve installed. The only big difference you&#8217;ll notice is that some of the menus have changed. We&#8217;ll use the GNOME desktop environment in the steps below, which is the default for many popular distributions like Ubuntu. If the directories are not created, you can create them using the mkdir command:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ mkdir &lt;directory name&gt;<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"344\" height=\"69\" class=\"wp-image-16956\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-320.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-320.png 344w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-320-300x60.png 300w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/p>\n<p>Select &#8220;cut&#8221; from the context menu when you right-click on the folder\/directory you want to relocate. You can also select the folder\/directory and cut it by pressing Ctrl + X on your computer.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"566\" class=\"wp-image-16957\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-321.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-321.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-321-300x234.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>Navigate to the location where you want the folder to be moved. &#8220;Paste&#8221; can be done by right-clicking in an empty space and selecting &#8220;paste.&#8221; Alternatively, go to the destination and paste the folder by pressing Ctrl + V on your keyboard.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"510\" class=\"wp-image-16958\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-322.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-322.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-322-300x210.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>You may also right-click a directory and choose &#8220;Move to&#8221; in various desktop environments.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"541\" class=\"wp-image-16959\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-323.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-323.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-323-300x222.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<p>Then, to finish the move, browse to the new location, highlight it, and click &#8220;select.&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"556\" class=\"wp-image-16960\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-324.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-324.png 736w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-324-300x227.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/p>\n<p>It&#8217;s as simple as that. It&#8217;s important to note that this will relocate the entire folder, including subdirectories. The command-line approach will be covered next.<\/p>\n<h2>Method 2: Move a Directory Using the Command Line Method<\/h2>\n<p>On Linux, the mv command is used to relocate directories (and files). Simply specifying a source and destination location in your command is the simplest version of the command. To access directories, you can use absolute or relative paths.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ mv &lt;directory1&gt; &lt;directory2&gt;<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"103\" class=\"wp-image-16961\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-325.png\" \/><\/p>\n<p>You can see that the above command will move the contents of \/d1 to \/d2.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"413\" height=\"180\" class=\"wp-image-16962\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-326.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-326.png 413w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-326-300x131.png 300w\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" \/><\/p>\n<p>But wait, if \/d2 doesn&#8217;t exist, then \/d1 would just be renamed to \/dir2 in such a scenario. In other words, when we use the mv command, we can give our relocated directory a new name. Simple relocation of the directory into an existing place will avoid having to supply a new name.<\/p>\n<p>You can also get more information about the relocation by using the -v (verbose) option. It&#8217;s worth noting that mv states it&#8217;s renaming the directory. Because paths are simply connections to files and folders on the hard disc, this is essentially the same as &#8220;moving&#8221; them.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ mv -v dir1 dir2<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"357\" height=\"111\" class=\"wp-image-16963\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-327.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-327.png 357w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-327-300x93.png 300w\" sizes=\"auto, (max-width: 357px) 100vw, 357px\" \/><\/p>\n<p>You can also transfer multiple directories at once. The destination directory for the rest of your command will be the final directory in your command.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ mv d1 d2 d3<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"337\" height=\"99\" class=\"wp-image-16964\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-328.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-328.png 337w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-328-300x88.png 300w\" sizes=\"auto, (max-width: 337px) 100vw, 337px\" \/><\/p>\n<p>By running this command, you can see that both d1 and d2 will be relocated to d3 in this case.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"422\" class=\"wp-image-16965\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-329.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-329.png 736w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/04\/word-image-329-300x172.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>In this article, we learned how to move directories on a Linux system using the GUI and the command line. This is a standard task that all users should be able to complete. The command-line method, as expected, gives us a little more control over the operation, but both methods are equally effective. You can choose the one among these two that is most convenient for you.<\/p>","protected":false},"excerpt":{"rendered":"<p>On Linux, moving a directory is a common activity that every user will have to do at some point. This can be done using any installed desktop environment&hellip;<\/p>","protected":false},"author":1,"featured_media":17015,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,891,5,83,165,2],"tags":[878,35],"class_list":["post-16955","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-manjaro","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-directory","tag-linux"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=16955"}],"version-history":[{"count":1,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16955\/revisions"}],"predecessor-version":[{"id":17014,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/16955\/revisions\/17014"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/17015"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=16955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=16955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=16955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}