June 13, 2026 · by Meegrow Labs

The mv Command: Move and Rename Files in the Terminal

Your desktop is a mess. Files are dumped everywhere, half of them named wrong, and finding anything feels like a small treasure hunt. You want to tidy up by shifting some files into folders and fixing a few names along the way.

Good news: in the terminal, one tool handles both jobs. That tool is the mv command, and once you get it, cleaning up becomes a two-second habit instead of a chore.

The mv command does two things with one word: it moves a file into a folder, or it renames a file in place. If the second name you give it is a folder, the file moves there. If it isn’t, the file gets that new name.

What does the mv command actually do?

Think of a file as a parcel with a label on it. Sometimes the parcel is in the wrong room and you just want to carry the whole box somewhere else. That’s moving.

Other times the box is fine, but the label is wrong, so you peel it off and stick on a new one. That’s renaming.

In the terminal, mv handles both of these everyday tasks. One tool, two powers, and no need to remember two separate commands.

How do I move a file with mv?

The shape of the command is simple. You type mv, then the file you want to move, then where you want it to go.

mv notes.txt docs/

Here, notes.txt is the file and docs/ is the destination folder. After you press Enter, the file lands neatly inside the docs folder. The slash at the end is a friendly reminder to yourself that docs is a folder.

How do I rename a file with mv?

Here’s the clever bit. If the second name you give isn’t a folder, the mv command renames the file instead of moving it.

mv notes.txt todo.txt

Because todo.txt is not a folder, the file simply gets a new name. Same file, same place, new label. It feels like two different commands, but it’s really just one command being smart about what you asked for.

Why does the mv command matter?

Because tidy files save you time. When everything has the right name and sits in the right folder, you stop hunting and start finding. That small bit of order adds up fast once you start building real projects.

This is also a close cousin of copying a file: copying leaves the original where it is and makes a duplicate, while moving picks the file up and relocates it. Knowing both means you’re always in control of your files.

How do I try the mv command right now?

The best way to learn this is to do it. Open your terminal and try this in three steps:

  • Make a folder, for example mkdir archive.
  • Move a file into it: mv myfile.txt archive/ and watch it slide right in.
  • Rename a file: mv myfile.txt diary.txt and see the new name appear.

Do it once and the mv command stops feeling technical and starts feeling like second nature. This is the kind of small, daily terminal skill we build step by step in the free Zero to AI Hero course, so you’re never stuck wondering what to type next.

Key takeaways

  • The mv command both moves and renames files, depending on what you give it.
  • If the second name is a folder, the file moves into that folder.
  • If the second name is not a folder, the file gets renamed.
  • The pattern is always mv <file> <destination-or-new-name>.
  • Tidy files save you time: you stop hunting and start finding.

Next up, we put all these terminal moves together so they become one smooth workflow.


🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.

Meegrow Labs

We help India go from zero to AI hero — learn to use & build with AI from scratch, in Hindi & English. Start the free course →

Want to actually learn this?

151 free 2-minute lessons — from "what's a file?" to building with AI.

▶ Start the free course