Networking / Beginners

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
[Previous] [Contents] [Next]