←
Command Line
/
Guided Lab Move and Rename with mv
60:00
Click the virtual machine below to start practicing
>_ Tekhnikum | Lab
- Setting up virtual machine…
- Preparing lab files…
- Starting terminal services…
This lab machine has stopped
Your progress through the guide is saved. Start a fresh machine to keep practicing.
Introduction
mv moves things, and renaming is just moving to a new name in the same place. Unlike cp, the original is gone afterwards.
This lab is the hands-on companion to the mv (Move) lesson from Linux Journey (CC BY-SA 4.0).
Rename a File
mv oldfile newfile
ls
Rename a Directory
Directories rename the same way, contents included:
mv drafts final
ls final
Move Several Files
List the files, then the destination directory last:
mv file_1 file_2 somedirectory/
ls somedirectory
Move with a Wildcard, Verbosely
-v reports each move, which is reassuring with wildcards:
mv -v *.txt Documents/
renamed 'a.txt' -> 'Documents/a.txt'
...
Summary
mv old new renames a file or directory.
mv a b dir/ moves several items into a directory.
- Wildcards move many files;
-v reports each move.