If you want to move a file in a Linux terminal, the command you need is almost always mv. It moves files and folders from one location to another, and it can rename them in the same step. Works the same on Ubuntu, Debian, CentOS, Kali pretty much every mainstream distro. If you're new to the Linux environment, our introduction to what is Ubuntu covers the basics of the most popular distro where you'll likely use these commands.
Quick examples to get you going:
mv file.txt /home/user/Documents/
mv oldname.txt newname.txt
mv file1.txt file2.txt /path/to/destination/
That's the whole game in three lines. The rest of this guide unpacks the edge cases wildcards, hidden files, folder moves, the -i and -n flags that save you from disasters, and the errors you'll bump into the first few times. For a broader set of commands every Linux user should know, bookmark our Ubuntu basic commands cheat sheet.
Move vs Rename in Linux
Here's a thing that trips up newcomers: Linux doesn't have a separate "rename" command in the GNU coreutils sense. mv handles both. If the destination is a different directory, you've moved the file. If the destination is a different name in the same directory, you've renamed it. If it's both — different directory and different name — you've done both at once. If you specifically need to rename files in bulk, see our guide on how to rename file in Linux.
Basic mv Syntax
mv [options] source destination
source can be a file, a folder, or several files. destination is where they're going — either a directory or a new filename.
How to Move a File in Linux
Move a File to Another Directory
mv file.txt /home/user/Documents/
Move and Rename a File at the Same Time
mv oldname.txt /home/user/Documents/newname.txt
Move a File to the Current Directory
mv /path/to/file.txt ./
Move a File to the Parent Directory
mv file.txt ../
How to Move Multiple Files in Linux
Move Multiple Specific Files
mv file1.txt file2.txt file3.txt /home/user/Documents/
Move Files by Extension with Wildcards
mv *.txt /home/user/Documents/TextFiles/
Move All Files from One Directory to Another
mv /source/* /destination/
Move Hidden Files Safely
shopt -s dotglobmv /source/* /destination/shopt -u dotglob
Move Files Matching a Pattern
find /source -type f -name "*.log" -exec mv -t /destination {} +
How to Move a Folder or Directory in Linux
Move a Folder to Another Directory
mv myfolder /home/user/backup/
Rename a Directory
mv old-folder-name new-folder-name
Move a Directory Without Overwriting Existing Files
mv -n project/ /archive/
How Ubuntu move file?

Moving files in Ubuntu using the terminal is a straightforward and powerful way to manage your data. Whether you're relocating a single file, renaming it in the process, or handling multiple files simultaneously, the mv command is the key tool. If you want to unzip files in Linux, read How to unzip files in Linux.
Understanding the mv Command

The mv command is used in Linux to move or rename files and directories. Here is the basic syntax:
mv [options] source destination
- source: The file or directory you want to move.
- destination: The target location where you want the file or directory to be moved.
For example, to move a file named example.txt to another directory:
mv example.txt /path/to/target/directory
How to Move Files in Linux Terminal
Let's explore common scenarios:
Move a single file to a specific directory:
mv file1.txt /home/user/documents/

Rename a file during the move:
mv oldname.txt /home/user/documents/newname.txt

Move files with a common pattern, such as all .txt files:
mv *.txt /home/user/documents/

Moving Multiple Files in Linux
Move multiple files to a single directory:
mv file1.txt file2.txt /home/user/documents/
Move all files of a specific type:
mv *.jpg /home/user/images/
Move files and directories together:
mv file1.txt dir1 /home/user/backup/
Ubuntu Move File to Another Directory
Simple file relocation:
mv document.txt ~/documents/
Use sudo if the target directory needs administrative permissions:
sudo mv config.conf /etc/configs/
Ensure that file properties like timestamps remain intact during the move:
mv --preserve file.txt /backup/
Examples of Ubuntu Move File Commands

Move report.pdf to the Reports directory:
mv report.pdf ~/Documents/Reports/
Move all .docx files to the WordFiles folder:
mv *.docx ~/Documents/WordFiles/
To avoid overwriting existing files, use the -i option:
mv -i file1.txt /backup/
Learning how to move files in Linux terminal is a vital skill for effective file management. By mastering the mv command, you can perform tasks like ubuntu move file, move file ubuntu, and mv multiple files seamlessly. Whether you're relocating individual files or handling complex scenarios such as linux move multiple files or linux mv multiple files, understanding these techniques ensures efficiency.
How CentOS move file?

Moving files in CentOS, a widely-used Linux distribution, is an essential skill for managing data efficiently. The mv command, a powerful Linux utility, enables users to move or rename files and directories. While this guide focuses on CentOS, the concepts are applicable to other Linux distributions like Ubuntu. If you want to check files creation, read How to check file creation time in Linux or ZIP files in Linux, read How to zip a file in Linux.
The mv Command: Basics
The mv command is the core tool for moving or renaming files in CentOS. Its syntax is simple:
mv [options] source destination
- source: The file or directory you want to move.
- destination: The target location or new name for the file or directory.
For example, to move a file named example.txt to another directory:
mv example.txt /home/user/documents/
How to Move Files in Linux Terminal
Move single files:
mv file1.txt /target/directory/
Rename files:
mv oldname.txt /target/directory/newname.txt
Use wildcards for multiple files:
mv *.txt /target/directory/
Moving Files to Specific Directories
Move file to another directory:
mv file.txt /home/user/documents/
Move file to folder:
mv file.txt /target/folder/
Move files to current directory:
mv /source/path/file.txt ./
Move file to usr/bin:
sudo mv script.sh /usr/bin/
Moving Files to Parent or Higher-Level Directories
Move files one folder up:
mv file.txt ../
Move files to parent directory:
mv file.txt ../parent_folder/
Move files up multiple directories:
mv file.txt ../../
Moving Multiple Files in CentOS
Specify multiple files:
mv file1.txt file2.txt /target/directory/
Using wildcards:
mv *.jpg /images/
Move files based on date:
find /source/ -type f -mtime -1 -exec mv {} /destination/ \;
Overwriting and Preserving Files
Avoid overwriting files:
mv -n file.txt /destination/
Interactive overwrite confirmation:
mv -i file.txt /destination/
Forced overwrite:
mv -f file.txt /destination/
How Debian move file?

Moving files in Debian Linux is an essential skill for effective file management. The process is nearly identical to how you would move files in Ubuntu since both are based on Debian architecture. If you're comparing Debian with Ubuntu for your next project, our Debian vs Ubuntu comparison covers the key differences that matter for server deployments.
Using the mv Command in Debian
mv [options] source destination
- source: The file or directory to move.
- destination: The target location or name.
For example, to move a file named example.txt to another directory:
mv example.txt /path/to/destination/
How to Move Files in Linux to Another Directory
Move a file to a specific folder:
mv file1.txt ~/Documents/
Rename the file while moving it:
mv file1.txt ~/Documents/renamed_file.txt
Move all .txt files:
mv *.txt ~/Documents/TextFiles/
Debian Move File to Parent Directory
Move a single file:
mv file1.txt ../
Move multiple files:
mv file1.txt file2.txt ../
Move all .log files to the parent directory:
mv *.log ../
Debian Move File to Folder
Move to a subfolder:
mv file1.txt subfolder/
Create the destination folder automatically:
mv --parents file1.txt new_directory/subfolder/
Move files with overwrite:
mv -f file1.txt subfolder/
Debian Move Files Up One Directory
Simple file movement:
mv file1.txt ../
Batch moving:
mv file1.txt file2.txt ../
Move with verification:
mv -i file1.txt ../
How Kali Linux move file?
Kali Linux, a Debian-based Linux distribution, is commonly used by professionals in penetration testing and ethical hacking. Managing files effectively is essential in any operating system, and Kali Linux is no exception. This guide covers how Kali Linux move file operations work.
Understanding the mv Command
The mv command in Linux is used to move or rename files and directories. Here is the basic syntax:
mv [options] source destination
- source: The file or directory to be moved.
- destination: The target location for the file or directory.
For example, to move a file named example.txt to another directory:
mv example.txt /path/to/target/directory
How to Move Files in Terminal Linux
Move file to another directory linux command:
mv file1.txt /home/user/documents/
Renaming files during move:
mv oldname.txt /home/user/documents/newname.txt
Using wildcards:
mv *.txt /home/user/documents/
How to Move Files in Linux to Another Folder
Basic file relocation:
mv report.pdf ~/reports/
Move all files from one directory to another:
mv /source/directory/* /destination/directory/
Move file with confirmation:
mv -i file1.txt /backup/
How to Move All Files from One Directory to Another in Linux
Moving all files:
mv /source/* /destination/
Preserving directory structure with rsync:
rsync -a /source/ /destination/
Handling hidden files:
mv /source/.* /destination/
Useful mv Options You Should Know
| Option | What It Does | Example | Best Use Case |
-i |
Prompts before overwriting | mv -i file.txt /backup/ |
Important files, manual moves |
-n |
Never overwrites existing files | mv -n *.log /var/log/old/ |
Bulk moves where collisions matter |
-f |
Forces overwrite without prompting | mv -f config.bak /etc/ |
Scripts where prompts would hang |
-v |
Verbose — prints each move | mv -v *.txt /docs/ |
Confirming what actually happened |
-u |
Moves only if source is newer | mv -u backup/* /archive/ |
Sync-style updates without rsync |
-t |
Specifies target directory first | mv -t /destination file1 file2 file3 |
Pairing with find ... -exec |
--backup |
Creates a backup before overwriting | mv --backup=numbered a.txt b.txt |
Safety copy automatically |
Common mv Errors and How to Fix Them
"No such file or directory"
mv: cannot stat 'report.txt': No such file or directory
Either the source doesn't exist, or you're not in the directory you think you are. Run pwd to see your current path and ls to confirm the file is there. If you need to navigate properly, our ls command in Linux guide covers the basics.
"Permission denied"
mv: cannot move 'config.ini' to '/etc/myapp/config.ini': Permission denied
You don't have write access to the destination. Fix it with sudo mv if you legitimately need root privileges. If you're unsure about root access conventions, read our guide on what are sudo privileges before running commands as root.
"Target Is Not a Directory"
mv: target 'documents' is not a directory
Either create the directory first (mkdir documents) or fix the path. Our guide on creating directories with mkdir walks through the syntax.
Overwriting Files by Accident
To prevent this, alias mv to mv -i in your ~/.bashrc:
alias mv='mv -i'
For more on handling files safely, see how to delete a file in Linux and how to recover deleted files in Linux if something goes wrong.
Problems with Spaces in File Names
Quote the path:
mv "my file.txt" "/home/user/My Documents/"
mv vs cp vs rsync vs scp
| Command | What It Does | Local or Remote | Best Use Case |
mv |
Moves or renames files; original is gone | Local only | Reorganising files on the same machine |
cp |
Copies files; original stays | Local only | Making duplicates, backups |
rsync |
Smart copy/sync — only transfers what changed | Local or remote | Backups, mirrors, incremental syncs |
scp |
Secure copy over SSH | Remote | Quick one-off transfers between servers |
When to Use cp
You want both versions to exist. See our guides on how to copy directories with cp in Linux and how to unzip files in Linux after transferring archives.
When to Use rsync or scp
For remote transfers, use SCP to transfer files to another server or rsync for efficient syncs. Trying to mv a file to a remote server? Doesn't work — mv has no SSH awareness.
Advanced Ways to Move Files in Linux
Using find with mv
find /var/log -type f -name "*.gz" -mtime +30 -exec mv -t /archive/old-logs {} +
Moving Files Older or Newer Than a Date
find . -type f -mtime +7 -exec mv -t /archive {} +find . -type f -mtime -1 -exec mv -t /recent {} +
If you want to filter files by time before moving them, our guide on how to check file creation time in Linux covers the commands you need.
Moving Files by Size or Type
find . -type f -size +100M -exec mv -t /large-files {} +
Moving Files with Bash Loops
for f in *.txt; do mv "$f" "processed_$f"done
If you're moving files you've just extracted or archived, see how to zip a file in Linux and how to find a file in Linux systems before relocating them.
Best Practices for Moving Files Safely
Preview Before Moving
ls *.logmv *.log /archive/
Quote File Paths with Spaces
Always. Even when you think there are no spaces.
Use Verbose and Interactive Flags
For anything important: mv -iv. You see what's happening, and you get a chance to back out.
Verify Destination Before Bulk Moves
ls -ld /destination/
For production servers, I'd strongly suggest aliasing mv to mv -i system-wide. Yes, it's annoying. Yes, it'll save your job one day. If you're managing files on a remote machine, a Linux VPS with full root access gives you the control you need to implement these safety measures properly.
| Command | Usage | Options | Best Used For | Pros | Cons |
| mv (move) | Moves files or directories to a different location. | -i, -u, -v | Simple local file or directory move. | Simple, fast, and direct. | No built-in option for backup or preserving metadata. |
| cp (copy) | Copies files or directories to a different location. | -r, -i, -v | Creating backups or file duplication. | Can preserve file attributes like timestamps. | Original files remain, uses more space. |
| rsync | Synchronizes files and directories efficiently. | -a, -z, -v | Remote or local large file sync. | Supports remote sync, compression, and efficiency. | More complex syntax, not ideal for basic use. |
Conclusion
Mastering file management through the Linux terminal is an essential skill for any user, whether you're working with a single file or managing multiple files simultaneously. By utilizing the versatile mv command, you can efficiently perform tasks like moving files to a different directory, renaming them, or even handling bulk transfers. The best way to build muscle memory with these commands is to practice on a live server an Ubuntu VPS gives you a full Linux environment with root access, so you can run mv, cp, and rsync in real scenarios without risking your local machine.
People also read:


Leave A Comment