How to move files in linux
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- The `mv` command is the primary command-line tool for moving files in Linux.
- You can move multiple files or entire directories at once with `mv`.
- Graphical file managers offer a visual drag-and-drop interface for moving files.
- Moving a file within the same filesystem is a very fast operation, as only the pointer is updated.
- Renaming a file is also achieved using the `mv` command by specifying a new name for the file.
Overview
Moving files is a fundamental operation in any operating system, and Linux offers versatile ways to accomplish this task, catering to both command-line enthusiasts and users who prefer a graphical interface. Whether you need to organize your documents, relocate program data, or simply tidy up your directories, understanding how to move files efficiently in Linux is essential.
Command-Line Method: The `mv` Command
The most common and powerful way to move files in Linux is through the command line, using the `mv` (move) command. This command is incredibly versatile and can be used for moving files, renaming files, and even moving directories.
Basic Syntax of `mv`
The general syntax for the `mv` command is:
mv [options] source destination
Where:
source: This is the file or directory you want to move. You can specify multiple sources if you wish to move them to the same destination.destination: This is the target directory where you want to move the source file(s) or directory. If the destination is an existing directory, the source(s) will be moved into it. If the destination is a new name and the source is a single file, the file will be renamed to that new name.
Examples of Using `mv`
1. Moving a single file to another directory:
mv mydocument.txt /home/user/documents/
This command moves the file `mydocument.txt` from the current directory to the `/home/user/documents/` directory.
2. Moving multiple files to a directory:
mv file1.txt file2.jpg image.png /home/user/backup/
This moves `file1.txt`, `file2.jpg`, and `image.png` into the `/home/user/backup/` directory.
3. Moving a directory:
mv myproject /opt/projects/
This moves the entire `myproject` directory and its contents to the `/opt/projects/` directory.
4. Renaming a file:
mv oldname.txt newname.txt
This command renames `oldname.txt` to `newname.txt` in the current directory. It doesn't actually move the file's location, but rather changes its name.
5. Renaming a directory:
mv old_dir new_dir
Similar to renaming a file, this renames the directory `old_dir` to `new_dir`.
Useful `mv` Options
-i(interactive): Prompts you before overwriting an existing file. This is a safety feature.-f(force): Overwrites existing files without prompting. Use with caution!-n(no-clobber): Prevents overwriting an existing file. If a file with the same name exists at the destination, the move will not occur for that file.-v(verbose): Explains what is being done. It will show each file being moved.
For instance, to move a file verbosely and be prompted if a file already exists:
mv -iv mydocument.txt /home/user/documents/
Graphical File Manager Method
For users who prefer a visual approach, Linux desktop environments provide graphical file managers. Popular examples include Nautilus (used in GNOME), Dolphin (used in KDE), Thunar (used in XFCE), and PCManFM (used in LXDE).
Using Drag and Drop
The process is very similar to how you would move files in Windows or macOS:
- Open your file manager.
- Navigate to the directory containing the file(s) or folder(s) you want to move.
- Open another file manager window or tab and navigate to the destination directory.
- Click and hold the left mouse button on the file(s) or folder(s) you want to move.
- Drag the selected item(s) to the destination directory window.
- Release the mouse button.
Most file managers will prompt you if you are about to overwrite an existing file. You can usually confirm or cancel the operation at this point.
Using Copy and Paste (or Cut and Paste)
You can also use the copy/paste or cut/paste functionality:
- Select the file(s) or folder(s) you want to move.
- Right-click on the selection and choose 'Cut' (or press Ctrl+X).
- Navigate to the destination directory.
- Right-click in an empty space within the destination directory and choose 'Paste' (or press Ctrl+V).
Using 'Cut' effectively moves the files after they are pasted. If you were to 'Copy' (Ctrl+C) and then 'Paste' (Ctrl+V), it would duplicate the files, leaving the originals in place.
Moving Files Between Different Filesystems
When you move a file within the same filesystem (e.g., from one directory to another on your main hard drive partition), the operation is extremely fast. This is because Linux doesn't actually copy the data; it simply updates the file's metadata (the directory entry) to point to the new location. This is a metadata operation, not a data transfer.
However, when you move a file between different filesystems (e.g., from your internal hard drive to a USB drive, or from one partition to another), Linux performs a copy operation followed by a delete operation. This means the data is actually transferred, and it will take longer depending on the file size and the speed of the storage devices involved.
Permissions and Ownership
When moving files, their ownership and permissions generally remain the same. The `mv` command does not change the owner or group of a file unless you are root (the administrator) and explicitly tell it to do so. Similarly, graphical file managers typically preserve these attributes.
Conclusion
Both the command-line `mv` command and the graphical file manager's drag-and-drop or cut-and-paste functions are effective ways to move files in Linux. The choice often depends on personal preference, the complexity of the task, and whether you are working in a terminal or a desktop environment. Understanding the nuances, especially regarding operations across different filesystems, will help you manage your files more efficiently.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- mv(1) - Linux man pageCC0-1.0
- Command line tools: move files - Ubuntu Tutorialsfair-use
- Coreutils: mv invocationGPL-3.0-or-later
Missing an answer?
Suggest a question and we'll generate an answer for it.