logo
search
list

Table of Content

Rename with mv
Rename vs Move
Extensions and Case
Common Failures
Rename Many Files (Carefully)
GUI Renames
Verify Success
Workflow Tip
After Renaming: Capture Naming Rules in a Document
FAQ
Free Office Download

Linux Rename File: Use mv the Right Way

Posted by Algirdas Jasaitis

calendar

2026-07-27

views

868

likes

59

This linux rename file guide shows how to rename a file in Linux: use mv oldname newname in the same directory. There is no separate beginner rename requirement for single files—GNU mv handles it. Use -i so you do not overwrite an existing target name. Success means ls shows the new name and the old name is gone.

Shortest path: mv draft.txt final.txt && ls -l final.txt. Renaming while relocating is still mv: mv draft.txt ~/Documents/final.txt. Related guides: create, copy, move.

Rename a file in Linux using mv
Renaming is mv with a new basename, optionally in another directory.
100% secure

To locate files before you create, copy, move, or delete them, see how to find files in Linux.

Rename with mv

mv old.txt new.txt
mv -iv "My Report.docx" "My-Report.docx"

Quote names with spaces or special characters. Tab-completion reduces typos. If tab-completion fails, you are probably in the wrong directory—run pwd and ls before inventing a new name.

Batch fancy renames (extension case changes, regex) may use the Perl rename utility or mmv—package names vary by distro. For one file, stick to mv as documented in mv(1). Resist the urge to install extra tools until mv itself is automatic.

Rename vs Move

Same directory + new basename = rename. Different directory = move (with optional rename). Both are mv. Copying to a new name uses cp and keeps the original.

Extensions and Case

mv Photo.JPG photo.jpg

On typical Linux filesystems, names are case-sensitive: File.txt and file.txt can both exist. Ask Ubuntu threads about lowercase extensions often automate with rename or loops—test on copies first.

cp Report.PDF Report.PDF.bak
mv Report.PDF report.pdf

Common Failures

  • Target exists: mv overwrites without -i
  • Permission denied: directory lacks write permission (renames need write on the directory)
  • Invalid name: slashes in names are path separators—cannot rename across implied directories without moving
  • Broken app links: shortcuts still point to old names
mv -i config.yaml config.yml
ls -l config.yml

Rename Many Files (Carefully)

Simple sequential renames in Bash:

i=1
for f in *.txt; do
  mv -i -- "$f" "chapter-$i.txt"
  i=$((i+1))
done

Always dry-run by echoing first:

for f in *.txt; do echo mv -i -- "$f" "backup-$f"; done

GUI Renames

File managers rename via context menu; under the hood they still change directory entries like mv. CLI knowledge helps on servers and WSL where GUIs are absent. If a GUI rename fails with permissions errors, the terminal error text is usually clearer—use it.

Document renames that affect URLs or published paths. A blog slug change is more than mv: update links, sitemaps, and redirects. The same mindset applies inside codebases—rename the file and update imports in one commit.

Verify Success

  1. Old name missing.
  2. New name present with expected size.
  3. Opening the file works in your editor.
  4. Scripts referencing the old name are updated.

Workflow Tip

Create with touch/editors, save drafts with temporary names, then rename to final names before moving into published folders. That reduces half-edited files in production directories.

Good naming conventions prevent rename churn: use lowercase, hyphens, and descriptive stems (invoice-acme-2026-07.pdf). Avoid relying on Finder/Explorer habits like Copy of Document (1).docx inside Linux projects—those spaces and parentheses demand quoting forever.

Batch regex renames are powerful and dangerous. On Ubuntu, the rename package historically differed between Perl and util-linux variants; check man rename on your machine before copying internet one-liners. When in doubt, a small Bash loop with echo dry-runs is clearer for teammates reviewing your script.

Case-only renames on case-insensitive mounts (some external drives) can no-op or collide. If mv File file misbehaves on a USB stick, rename to a temporary third name first: mv File tempname && mv tempname file.

Applications cache paths: browsers, IDEs, and backup tools may keep old filenames in recent-file lists. After renaming configs, restart the service or update unit files. For code, run tests after mass renames; string references inside files do not change when the path changes.

International characters are valid in modern UTF-8 locales but complicate SSH clients and legacy tools. Prefer ASCII names for scripts shared across systems. You can still store human titles inside document metadata or first headings.

Atomic save patterns in editors sometimes write file.txt.tmp then rename to file.txt. That is mv under the hood and explains why brief temp files appear. Do not delete unknown temp names while editors are open.

Practice drill: create three files, rename them to a sequence, move them into done/, and copy one backup aside. That single drill ties together create, rename, move, and copy—the core Linux file hygiene set. Repeat it on a new VPS once so SSH latency does not surprise you later.

When renaming for publication, prefer stable names early. Changing draft-3.md to a final slug after reviewers already linked it creates churn. Agree on the final filename before you share URLs, then mv only to fix typos—not to rethink branding weekly. Stable names are a gift to future you and to every script that hardcodes the path across servers and laptops.

If a rename feels risky, copy first, rename the copy, verify, then remove the old name. That slower path is still faster than restoring from backups after an overwrite. For shared documents, announce the new name in chat so nobody searches for a ghost filename tomorrow morning—and update bookmarks the same day while the change is fresh. Small communication beats large recovery every single time you rename shared files at work today. Pause one beat, then proceed.

Linux rename file operations are mv old new—quote special characters, use -i to protect existing targets, and test batch renames on copies first.

Practice in a scratch directory such as ~/tmp-practice before touching production paths. Run ls -la after each experiment so you see hidden files and permissions. Build muscle memory with short daily drills: create, copy, move, rename, then clean up. Ten focused minutes beats an hour of panicked forum searching after a bad glob.

When scripts grow beyond one-liners, add careful Bash options and quote variables. Most file disasters come from unquoted globs and wrong working directories—not from the tools themselves. Keep a personal gist of safe snippets you have tested on your distro version.

Read the relevant man page once end to end (man touch, man cp, or man mv). You do not need every flag memorized; you need to know which section to skim when something odd happens. Official man pages beat random screenshots that omit destructive defaults.

On multi-user systems, communicate before mass renames or directory moves. A teammate’s cron job may still point at yesterday’s path. Chat first, change second, and leave a symlink temporarily when you must keep old paths alive during migration windows.

Backups turn irreversible mistakes into inconveniences. Even a crude cp -a ~/project ~/backups/project-$(date +%F) before experiments is enough for personal machines. Servers should already have snapshots; do not invent ad-hoc production edits without a ticket and a restore plan.

After you create or rearrange files on Linux, many workflows still end in DOCX, XLSX, or PDF for schools and workplaces. Keep an office suite available on the same machine or on Windows when you need print-ready documents from notes you drafted in the terminal.

If you work across WSL and Windows, decide which side owns the “source of truth” files. Edit in Linux home for code, export finished office documents to Windows only when sharing requires it. That boundary prevents half-saved files and permission weirdness on /mnt/c.

Teach teammates the same four verbs—create, copy, move, rename—before introducing find/xargs pipelines. Solid basics prevent clever one-liners from destroying directories. When someone asks for “just the command,” still mention -i, quoting, and verifying with ls.

Keep this mental model: touch/editors create, cp duplicates, mv relocates or renames, and rm deletes. Mixing them up is how backups become deletes and deletes become disasters. Slow down for production paths; go fast only inside throwaway practice folders you can rebuild in seconds.

After Renaming: Capture Naming Rules in a Document

mv renames are instant in the shell. Naming conventions for datasets, deliverables, or course folders are easier to share when they live in a short written guide.

WPS Office for Linux is a simple place for that guide: Writer for rename rules, Spreadsheet for old→new maps, and PDF when the convention should not drift.

WPS Office Writer on Linux editing project notes and file workflow steps in a DOCX
WPS Writer on Linux: paste command results and folder plans into a clean DOCX for handoff.
What you need nextWhat WPS gives you
Publish rename conventions as a shareable noteStrong .docx / .xlsx / .pptx layout fidelity when files move between Linux, Windows, and macOS
One place for notes, sheets, slides, and PDFsFree core suite: Writer, Spreadsheet, Presentation, plus PDF view/edit/convert tools
A familiar desktop UI for switchersRibbon-style apps with a lighter footprint than many heavy suites
A trusted install pathOfficial DEB (Ubuntu/Debian/Mint) and RPM packages from the vendor

Download from the official WPS Office for Linux download page, install with sudo apt install ./wps-office_VERSION_amd64.deb, and keep the naming map beside the files you just renamed.

WPS WriterWPS PresentationWPS SpreadsheetWPS PDF
Rename and Edit Documents with WPS Office Free

FAQ

Is there a rename command?

Some distros ship a rename utility for batch patterns; single-file renames use mv everywhere. Always check which rename implementation your package provides.

Can I rename a directory the same way?

mv old-dir new-dir

Why can’t I rename across devices with a new name?

You can—mv accepts a destination path on another mount—but it becomes a copy+delete. Verify free space and consider explicit cp verification for critical data.

How do I rename hidden files?

mv .oldname .newname
ls -la .newname

Does renaming change file content?

No. Only the path/name changes on the same filesystem. Content hashes stay the same.

What about undo?

mv back to the old name if known. Version control (git) is safer for code trees and provides history.

How do I rename only the extension?

mv document.TXT document.txt

Can two files differ only by case?

Yes on typical Linux filesystems. Be careful when syncing to case-insensitive platforms like default Windows/macOS volumes.

Free Office Download

WPS WriterWPS PresentationWPS SpreadsheetWPS PDF
  • Use Word, Excel, and PPT for FREE, No Ads.

  • Edit PDF files with the powerful PDF toolkit.

  • Microsoft-like interface. Easy to learn. 100% Compatibility.

  • Boost your productivity with WPS's abundant free Word, Excel, PPT, and CV templates.

100% secure
Algirdas Jasaitis

15 years of office industry experience, tech lover and copywriter. Follow me for product reviews, comparisons, and recommendations for new apps and software.