Last updated:

Quick answer: use mv source destination. For example, mv report.txt ~/Documents/ moves report.txt into the Documents folder. To move several files, list them all and end with the destination folder: mv file1.txt file2.txt samples/. Add -i to be asked before overwriting.

Almost all Linux distributions allow us to create, delete, and move files. One of the most frequent tasks while using Linux is moving files and folders from one place to another

This guide will demonstrate how to move files to other folders in Linux using the command line terminal and GUI.

How do I move a file to another folder in Linux?

To move a single file or multiple files to another folder or simply change the directory of a file, two methods are frequently used.

  • Using Command-Line
  • Using GUI

Let’s discuss them one by one.

Method 1: Move a File to Another Folder in Linux Using Command Line

To change the directory of a file, we can use the mv command. This command changes the location of the file to the specified directory etc.

The syntax of the mv command is demonstrated below:

$ mv file.txt dir

For instance, we can see that the sample.txt file is present in the home directory

File manager showing the Home folder with sample.txt highlighted before it is moved
Terminal running the mv command to move sample.txt into the Documents directory

It can be seen that the directory of the file is changed from Home to Home/Documents.

File manager showing sample.txt now inside the Documents folder

Let’s change the location of multiple files using the mv command.

The syntax is as follows:

$ mv file1 file2 dir

We can see that the two files named file1.txt and file2.txt are in the home directory. Let’s move them into the samples directory

Stuck at this step? Ask us, it is free and include the exact error.

File manager showing file1.txt and file2.txt in the Home folder with an arrow pointing to the samples folder
Terminal running mv with two file names and the samples directory as the destination

It can be seen that the location of the files has been changed successfully.

File manager showing file1.txt and file2.txt inside the samples folder after the move

Method 2: Move a File to Another Folder in Linux Using GUI

A simple and most commonly used method to change the location of files and directories is the GUI (Graphical User Interface) method.

Let’s demonstrate this method with the help of an example:

We can see that the workfile.txt is currently in the home directory. Let’s change its location.

File manager showing workfile.txt in the Home folder with an arrow pointing to the Samples folder

Right-click on the file and select Move to Button.

Right-click context menu on a file with the Move to option highlighted

Now choose the folder where you want to locate your file. In our case, it’s the Samples folder.

Folder chooser dialog with the Samples folder selected as the destination

It can be seen that the directory of the workfile.txt is changed from Home to Home/Samples.

File manager showing workfile.txt inside the Samples folder after the move

mv options that prevent mistakes

By default mv silently replaces a file with the same name in the destination folder, and there is no undo. These options make it safer. I ran each one on Ubuntu 24.04 (GNU coreutils 9.4):

OptionWhat it doesObserved behaviour
-vVerbose: prints each moverenamed 'file1.txt' -> 'samples/file1.txt'
-iAsks before overwritingPrints mv: overwrite 'Documents/sample.txt'? and keeps the old file if you answer n
-nNever overwrites an existing filePrints mv: not replacing 'Documents/sample.txt' and exits with status 1 on coreutils 9.4
-t DIRNames the destination first, handy with xargsmv -v -t samples/ Documents/sample.txt moved the file into samples/

Two more things worth knowing. File names with spaces need quotes, for example mv "my file.txt" "My Folder/". And mv is also how you rename a file: mv old-name.txt new-name.txt keeps it in the same folder under the new name.

mv -iv report.txt ~/Documents/

Conclusion

To locate a single file or multiple files to other folders in Linux, two methods are frequently used such as the Command line method and the GUI method. In the command line, use the mv file.txt dir command to change the location of a single file. In the GUI method, simply right-click the file that you want to move, select Move to, and simply select the folder where you want to locate your file. This write-up has illustrated how to move files to other folders in Linux using the command line terminal and GUI.