Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Move Files Using Linux Commands or File Managers

#1
How to Move Files Using Linux Commands or File Managers

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2018/11/how-to-move-files-using-linux-commands-or-file-managers.jpg" width="550" height="433" title="" alt="" /></div><div><p class="western"><strong>Learn how to move files with Linux commands in this tutorial from our archives.</strong></p>
<p class="western">There are certain tasks that are done so often, users take for granted just how simple they are. But then, you migrate to a new platform and those same simple tasks begin to require a small portion of your brain’s power to complete. One such task is moving files from one location to another. Sure, it’s most often considered one of the more rudimentary actions to be done on a computer. When you move to the Linux platform, however, you may find yourself asking “Now, how do I move files?”</p>
<p class="western">If you’re familiar with Linux, you know there are always many routes to the same success. Moving files is no exception. You can opt for the power of the command line or the simplicity of the GUI – either way, you will get those files moved.</p>
<p class="western">Let’s examine just how you can move those files about. First we’ll examine the command line.</p>
<h2 class="western"><b>Command line moving</b></h2>
<p class="western">One of the issues so many users, new to Linux, face is the idea of having to use the command line. It <i>can </i>be somewhat daunting at first. Although modern Linux interfaces can help to ensure you rarely have to use this “old school” tool, there is a great deal of power you would be missing if you ignored it all together. The command for moving files is a perfect illustration of this.</p>
<p class="western">The command to move files is <code>mv</code>. It’s very simple and one of the first commands you will learn on the platform. Instead of just listing out the syntax and the usual switches for the command – and then allowing you to do the rest – let’s walk through how you can make use of this tool.</p>
<p class="western">The <code>mv </code>command does one thing – it moves a file from one location to another. This can be somewhat misleading, because <code>mv </code>is also used to rename files. How? Simple. Here’s an example. Say you have the file testfile in /home/jack/ and you want to rename it to testfile2 (while keeping it in the same location). To do this, you would use the <code>mv </code>command like so:</p>
<p class="western"><code>mv /home/jack/testfile /home/jack/testfile2</code></p>
<p class="western">or, if you’re already within /home/jack:</p>
<p class="western"><code>mv testfile testfile2</code></p>
<p class="western">The above commands would move /home/jack/testfile to /home/jack/testfile2 – effectively renaming the file. But what if you simply wanted to move the file? Say you want to keep your home directory (in this case /home/jack) free from stray files. You could move that testfile into /home/jack/Documents with the command:</p>
<p class="western"><code>mv /home/jack/testfile /home/jack/Documents/</code></p>
<p class="western">With the above command, you have relocated the file into a new location, while retaining the original file name.</p>
<p class="western">What if you have a number of files you want to move? Luckily, you don’t have to issue the <code>mv </code>command for every file. You can use wildcards to help you out. Here’s an example:</p>
<p class="western">You have a number of .mp3 files in your ~/Downloads directory (~/ – is an easy way to represent your home directory – in our earlier example, that would be /home/jack/) and you want them in ~/Music. You could quickly move them with a single command, like so:</p>
<p class="western"><code>mv ~/Downloads/*.mp3 ~/Music/</code></p>
<p class="western">That command would move every file that ended in .mp3 from the Downloads directory, and move them into the Music directory.</p>
<p class="western">Should you want to move a file into the parent directory of the current working directory, there’s an easy way to do that. Say you have the file testfile located in ~/Downloads and you want it in your home directory. If you are currently in the ~/Downloads directory, you can move it up one folder (to ~/) like so:</p>
<p class="western"><code>mv testfile ../</code> </p>
<p class="western">The “../” means to move the folder up one level. If you’re buried deeper, say ~/Downloads/today/, you can still easily move that file with:</p>
<p class="western"><code>mv testfile ../../</code></p>
<p class="western">Just remember, each “../” represents one level up.</p>
<p class="western">As you can see, moving files from the command line, isn’t difficult at all.</p>
<h3 class="western"><b>GUI</b></h3>
<p class="western">There are a lot of GUIs available for the Linux platform. On top of that, there are a lot of file managers you can use. The most popular file managers are Nautilus (GNOME) and Dolphin (KDE). Both are very powerful and flexible. I want to illustrate how files are moved using the Nautilus file manager (on the Ubuntu 13.10 distribution, with Unity as the interface).</p>
<p class="western">Nautilus has probably the most efficient means of moving files about. Here’s how it’s done:</p>
<ol>
<li>
<p class="western">Open up the Nautilus file manager.</p>
</li>
<li>
<p class="western">Locate the file you want to move and right-click said file.</p>
</li>
<li>
<p class="western">From the pop-up menu (<b>Figure 1</b>) select the “Move To” option.</p>
</li>
<li>
<p class="western">When the Select Destination window opens, navigate to the new location for the file.</p>
</li>
<li>
<p class="western">Once you’ve located the destination folder, click Select.</p>
</li>
</ol>
<p class="western"><img alt="Nautilus screenshot" class="caption" height="433" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/11/how-to-move-files-using-linux-commands-or-file-managers.jpg" title="From the pop-up menu select the “Move To” option." width="550" /></p>
<p class="western">This context menu also allows you to copy the file to a new location, move the file to the Trash, and more.</p>
<p class="western">If you’re more of a drag and drop kind of person, fear not – Nautilus is ready to serve. Let’s say you have a file in your home directory and you want to drag it to Documents. By default, Nautilus will have a few bookmarks in the left pane of the window. You can drag the file into the Document bookmark without having to open a second Nautilus window. Simply click, hold, and drag the file from the main viewing pane to the Documents bookmark.</p>
<p class="western">If, however, the destination for that file is not listed in your bookmarks (or doesn’t appear in the current main viewing pane), you’ll need to open up a second Nautilus window. Side by side, you can then drag the file from the source folder in the original window to the the destination folder in the second window.</p>
<p class="western">If you need to move multiple files, you’re still in luck. Similar to nearly every modern user interface, you can do multi-select of files by holding down the Ctrl button as you click each file. After you have selected each file (<b>Figure 2</b>), you can either right-click one of the selected files and the choose the Move To option, or just drag and drop them into a new location.</p>
<p class="western"><img alt="nautilus" class="caption" height="308" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/11/how-to-move-files-using-linux-commands-or-file-managers-1.jpg" title="After you have selected each file, you can either right-click one of the selected files and the choose the Move To option, or just drag and drop them into a new location." width="550" /></p>
<p class="western">The selected files (in this case, folders) will each be highlighted.</p>
<p class="western">Moving files on the Linux desktop is incredibly easy. Either with the command line or your desktop of choice, you have numerous routes to success – all of which are user-friendly and quick to master.</p>
</div>
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016