The mv command
The mv command moves files or renames them. In Linux, moving and renaming a file is essentially the same thing. Moving a file changes the file's directory location but leaves its name the same. Renaming a file leaves the file in the same directory but changes the file's name.
The syntax of the mv command is
mvp [options] source-file destination
The following paragraphs describe the options:
- -b: Makes backup copies of existing files before they're overwritten. Sounds like a good plan to me.
- -f: Removes files that will be overwritten.
- -i: Interactively prompts for each file to be overwritten.
- -u: Replaces destination files only if the source file is newer.
To move a file to another directory, provide a filename for the first argument and a directory for the second, like this:
$ mv monthly.report /home/Debbie/
To rename a file, provide filenames for both arguments:
$ mv monthly.report august.monthly.report
In this tutorial:
- Linux Commands
- Command Shell Basics
- Editing commands
- Wildcards
- Redirection and piping
- Environment variables
- Shell scripts
- Directory and File Handling Commands
- The cd command
- The mkdir command
- The rmdir command
- The ls command
- The cp command
- The rm command
- The mv command
- The touch command
- The cat command
- Commands for Working with Packages and Services
- The rpm command
- Commands for Administering Users
- The usermod command
- The chage command
- The passwd command
- The newusers command
- The groupadd command
- The groupdel command
- Commands for Managing Ownership and Permissions
- The chgrp command
- The chmod command
- Networking Commands
- The ipconfig command
- The netstat command
- The ping command
- The route command
- The traceroute command