mv — move and rename files
Command to move or rename files and folders. Rollback and cleanup examples, overwrite prevention, and execution screen.
💬 "mv command"
- Concept: Short for Move, it moves files or folders to another location or renames them. Unlike copying, the original is not kept.
- Output structure: If successful, it prints nothing. Add
-vto show the moved result one line at a time. - Recommended output in practice: Use
mv -vto keep a log of operations, and use-ito prevent accidentally overwriting existing files. - Left column: Shows the path or name of the source to be moved.
- Right column: Shows the path or new name after it has been moved.
3 Essential Command Combinations
mv a b— Change the file name to bmv a dir/— Move the file to another foldermv -i a dir/— Confirm before overwriting
Here are some useful options to know.
-n— Skip without overwriting if the destination already exists-v— Display the move result one line at a time
💬 "Show me an example of how you use this in practice."
Scenario: A new deployment has a problem, and you need to roll back to the previous version.
Step 1: Mark the previous version
Move the current deployment to a backup name.
mv -v app app.old
Step 2: Apply the new deployment
Move the deployment that was on standby to the service name.
mv -v app.new app
Step 3: Verify the result
Check the folder list.
ls -al
Actual execution screen
This is an example screen of renaming a file with mv -v.
!mv command execution result: displays the move from the original to the new name
An actual production server
Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/mv.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments