Classic SysAdmin: How to Move Files Using Linux Commands or File Managers - Linux Foundation (2024)

Table of Contents
Command line moving GUI FAQs

5 MIN READ

The Linux Foundation | 05 January 2022

This is a classic article written by Jack Wallen from theLinux.comarchives. For more great SysAdmin tips and techniques check out our free intro to Linux course.

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?”

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.

Let’s examine just how you can move those files about. First, we’ll examine the command line.

Command line moving

One of the issues so many users new to Linux face is the idea of having to use the command line. It can 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 altogether. The command for moving files is a perfect illustration of this.

The command to move files is mv. 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.

The mv command does one thing – it moves a file from one location to another. This can be somewhat misleading because mv 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 mv command like so:

mv /home/jack/testfile /home/jack/testfile2

or, if you’re already within /home/jack:

mv testfile testfile2

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:

mv /home/jack/testfile /home/jack/Documents/

With the above command, you have relocated the file into a new location, while retaining the original file name.

What if you have a number of files you want to move? Luckily, you don’t have to issue the mv command for every file. You can use wildcards to help you out. Here’s an example:

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:

mv ~/Downloads/*.mp3 ~/Music/

That command would move every file that ended in .mp3 from the Downloads directory, and move them into the Music directory.

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:

mv testfile ../

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:

mv testfile ../../

Just remember, each “../” represents one level up.

As you can see, moving files from the command line isn’t difficult at all.

GUI

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.

Nautilus has probably the most efficient means of moving files about. Here’s how it’s done:

  1. Open up the Nautilus file manager.
  2. Locate the file you want to move and right-click said file.
  3. From the pop-up menu (Figure 1) select the “Move To” option.
  4. When the Select Destination window opens, navigate to the new location for the file.
  5. Once you’ve located the destination folder, click Select.
Classic SysAdmin: How to Move Files Using Linux Commands or File Managers - Linux Foundation (1)

This context menu also allows you to copy the file to a new location, move the file to the Trash, and more.

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.

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 destination folder in the second window.

If you need to move multiple files, you’re still in luck. Similar to nearly every modern user interface, you can do a multi-select of files by holding down the Ctrl button as you click each file. After you have selected each file (Figure 2), you can either right-click one of the selected files and then choose the Move To option, or just drag and drop them into a new location.

Classic SysAdmin: How to Move Files Using Linux Commands or File Managers - Linux Foundation (2)

The selected files (in this case, folders) will each be highlighted.

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.

Classic SysAdmin: How to Move Files Using Linux Commands or File Managers - Linux Foundation (2024)

FAQs

How do I move a file in Linux using commands? ›

Moving and renaming files (mv command)
  1. To move a file to another directory and give it a new name, type the following: mv intro manual/chap1. This moves the intro file to the manual/chap1 directory. ...
  2. To move a file to another directory, keeping the same name, type the following: mv chap3 manual.

How do you move files around in Linux? ›

To move a file in a terminal, you use the mv command to move a file from one location to another. In this example, you've moved example. txt from its current folder into the Documents folder.

What is the command for file transfer in Linux? ›

scp (secure copy) command in Linux system is used to copy file(s) between servers in a secure way. The SCP command or secure copy allows the secure transferring of files between the local host and the remote host or between two remote hosts.

What is the cp command to move files? ›

“cp” command is used to copy files and directories. It requires at least two arguments. To copy file file1 to a new file file2, issue “cp file1 file2” command.

How do I move or copy a file or directory in Linux? ›

You use the cp command for copying files from one location to another. This command can also copy directories (folders). [file/directory-sources] specifies the sources of the files or directories you want to copy. And the [destination] argument specifies the location you want to copy the file to.

What is the command to move a folder in Linux? ›

The most common and versatile command for moving directories in Linux is mv. The mv command is primarily used for renaming files and directories, but it can also be utilized to move directories from one location to another.

How do you move all files in a file in Linux? ›

Simply use mv folder1/folder2/* <destination> . This command will move all files in folder1/folder2 to your specified destination.

How do I move files from local to Linux? ›

To transfer files, we can simply drag and drop files to the Linux system. Notably, files can be transferred from and to either side. Basically, to transmit data, SFTP relies on the SSH protocol. Thus, it creates an encrypted connection between the systems.

What is chmod 777 command? ›

The `chmod 777` command is used in Unix-based systems (such as Linux or macOS) to change the permissions of a file or directory.

What are the examples of file transfer commands? ›

FTP commands for Windows command prompt
FTP CommandDescription of Command
putSend one file.
pwdPrint working directory.
quitExits from FTP.
quoteSame as the literal command.
38 more rows

How do you move files? ›

Move files to an existing folder in internal storage
  1. On your Android device, open Files by Google .
  2. Under 'Categories', select a category.
  3. Find the files that you'd like to move. To move one file: In grid view : ...
  4. Tap Internal storage.
  5. Choose the folder into which you'd like to move the file.
  6. Tap Move here.

Which command is used to move files and directories? ›

Move Files/Directories

To move the content of a file/directory to another directory, you just use the mv command.

What is the cp command for all files and folders? ›

The cp command also copies entire directories into other directories if you specify the -r or -R flags. You can also copy special-device files using the -R flag. Specifying -R causes the special files to be re-created under the new path name.

How do I move an executable file in Linux? ›

Just copy it to a thumb drive or over the network like any other file. There aren't a *lot* of these (well, there are, but we're usually talking utilities.) Other applications will have a host of other files that that .exe file needs, but will still let you just move the folder they're in, like any other file.

How do you move files in Linux MC? ›

To copy or move a file, select it from the file list and press the F5 key. By default, mc prompts you to copy (or move) your active selection from to the location shown in the non-active panel.

Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 6039

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.