Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · file management

mv

move, which is also rename

mv moves things, and there is no separate rename command because renaming is moving to a new name in the same place. Within one filesystem it is instant whatever the size; across two, it copies the data and then deletes the original.

Inside one filesystem, mv changes only the name the data is filed under — the data itself never moves.

Shape
mv SOURCE DEST
a new name or a directory
Renames
Yes
the same command
Overwrites
Silently
-i asks, -n refuses
Directories
No flag needed
unlike cp and rm

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashcoreutils
$ mv -v report.txt archive/
1renamed 'report.txt' -> 'archive/report.txt'
$ mv -v draft.md final.md
2renamed 'draft.md' -> 'final.md'
3$ mv -n notes.txt archive/
$ mv -v big.iso /mnt/usb/
4copied 'big.iso' -> '/mnt/usb/big.iso'
removed 'big.iso'
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
The destination is a directory, so the file goes into it

The name is kept. mv calls it "renamed" because that is literally what happened to the path.

2
The destination is a new name, so it is a rename

Same directory, different name. Nothing was copied.

3
-n refuses to overwrite

archive/notes.txt already existed, so mv did nothing and said nothing. Without -n it would have replaced it.

4
Across filesystems it is a copy and a delete

The USB stick is a different filesystem, so the data really had to travel. This is the slow case, and the one that can fail halfway.

Switches

A switch changes how the command behaves. These are the ones used day to day; man mv lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-i
Interactive: ask before overwriting an existing file.
-n
No-clobber: never overwrite an existing file.
-u
Update: move only when the source is newer than the destination.
-f
Force: overwrite without asking, even if -i was set by an alias.
-v
Verbose: print each file as it is moved or renamed.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

mv -i *.log old/

Moves several files into a directory, asking before any overwrite.

mv old-name/ new-name/

Renames a directory — no recursive flag is needed.

mv -b config.yaml /etc/app/

Keeps a backup of any file it would have overwritten, with a ~ on the end.

mv -- -odd-name.txt fixed.txt

The double dash ends the options, so a name starting with a dash is treated as a file.

In cybersecurity

mv has no undo and no warning when the destination exists, and it carries a file's old permissions to its new home.

Overwriting is silent

Moving onto an existing name destroys what was there. -n in scripts and -i at the prompt are cheap insurance.

Permissions travel with the file

A file moved into a web root keeps the owner and mode it had before. Check them after the move, not before.

Replacing a file atomically

Writing a new version beside the old one and then mv-ing it over is the safe way to update a config: readers see the old file or the new, never half of each.

Filed under

File management

Read alongside