How to Move Files and Directories in Linux (With 6 Examples)

Moving files and directories in Linux is an important task that allows you to reorganize your file structure, create backups, free up space, share files with others, and access files from different locations. It is a useful and necessary task to help you manage your data and improve productivity.

This post will instruct you on how to move files and directories in Linux. The practical implementation of the steps is carried out on Linux Mint 21.

How to Move Files and Directories in Linux Using CLI?

The mv command is used to move files and directories in Linux. The basic syntax for the mv command is as follows:

Syntax of the mv Command

$ mv [options] source destination

While the ‘source’ and ‘destination’ represents the current location and the location to which the file will be moved. 

Examples of Moving Files in Linux

The following examples demonstrate how files can be moved in Linux.

Example 1: Moving a File to a Different Directory

The simple move is shown in the following command, where the file named “genie1.txt” will be moved to the directory “/home/linuxgenie/data”.

$ mv genie1.txt /home/linuxgenie/data

Example 2: Moving File With a Space in the Name

Now, if there is a space in the file name, it can be moved by putting the file name in the double quotations as practiced in the following command.

$ mv "genie file.txt" ~/data

Example 3: Move a File Having Special Character in Its Name

If there is a character in the file name, you need to put the backslash before the character. The file named “genie@” will be moved using “genie\@”, as seen below. 

$ mv "genie\@.txt" ~/data

Example 4: Moving Multiple Files

The multiple files can be moved using the file names in a sequence and then putting the destination directory’s address. The following command moves 3 files to the target directory.

$ mv genie1.txt genie2.txt genie3.txt ~/data

Example 5: Move and Rename File Simultaneously

The files can be moved and placed with a different name. As an example, the command written below will move the file named genie.txt and will move it to a different directory and will name it “GenieTest.txt”.

$ mv genie.txt GenieTest.txt ~/data

Example 6: Move Files of Specific Category

Using the wild card character, the file’s category can be mentioned; thus, only selected files will be moved to the destination directory. 

The wild card can be mentioned with the extension name, and that file will be moved only. An example of such a scenario is seen below, where all the files with a .txt extension will be moved to the destination directory.

$ mv *.txt ~/data

Examples of Moving Directories in Linux

Now, let’s practice the examples of moving directories in Linux.

Example 1: Moving a Directory to a Different Directory

The command below will move the directory named linuxgenie to the destination directory /home/linuxgenie/data.

$ mv linuxgenie ~/data

Example 2: Moving Multiple Directories

To move multiple directories with all their content, use the recursive flag with all the directory’s names as follows.

$ mv genie1 genie2 genie3 ~/data

The recursive move feature will move the sub-directories and all the files inside those directories.

Example 3: Move All Directories/Files From the Current Directory

You can use the wild card character (*) to move everything from the current directory to the destination directory, as demonstrated in the command written below.

$ mv * ~/data

Example 4: Files/Directories Starting or Ending With a Specific Character/Word

The wild card is the primary catalyst for selecting multiple files/directories. For instance, the command provided below will select and move all the file directories started with the name gen. 

$ mv gen* ~/data

How to Move Files and Directories in Linux Using GUI?

If your Linux system is equipped with any desktop environment, you can use the GUI to move files/directories. The process of moving files/directories is the same throughout all the desktop environments. For instance, we are using the Linux Mint 21 Cinnamon and the process is listed below. 

Locate the file or directory you want to move, then right-click on it. Choose the option cut from the dropdown menu, as seen below. (you can cut the file/directory using the shortcut key CTRL+SHIFT+X/CTRL+X)

Now, go to the destination directory and right-click there. Choose the paste option from the dropdown menu. (you can cut the file/directory using the shortcut key CTRL+SHIFT+S/CTRL+S).


Linux offers a list of easy-to-use commands to manage files and directories. If we talk about moving files/directories specifically, then the ‘mv’ command is used the most. By the end of this post, you will have learned the practical implementation of the ‘mv’ command to move files and directories in Linux.

Print Friendly, PDF & Email