📖 How to Move and Rename Files in Linux
Learn how to relocate files, rename folders, and perform safe bulk file moves in Linux terminals.
1. Renaming a File
In Linux, renaming a file and moving a file use the exact same command: mv.
$ mv original_name.txt new_name.txt
2. Moving a File into Another Folder
Specify the destination directory path as the second argument:
$ mv invoice.pdf /home/user/documents/
3. Moving Multiple Files at Once
List all source files followed by the target folder:
$ mv file1.txt file2.txt file3.txt /home/user/archive/
4. Moving Files with Wildcards (*, ?)
To move all files matching a specific pattern (such as all PNG images or log files):
$ mv *.png /var/www/assets/images/
$ mv error_2026-*.log /var/log/old/
$ mv error_2026-*.log /var/log/old/
5. Safe Moving: Prevent Accidental Overwrite
By default, mv silently overwrites destination files with the same name. Use these safety flags:
mv -i file.txt dest/— Prompts overwrite? (y/n) before replacing.mv -n file.txt dest/— No-clobber: Never overwrites an existing file.mv -u file.txt dest/— Only moves if the source is newer than the destination copy.