Moving or Renaming a File with mv

In Linux land, moving and renaming a file are the same thing. It doesn’t matter whether you are moving the directory to another or from one filename to another filename in the same directory, there is only one command to remember. To move a file named filename from ~/documents to ~/archive, use this command:

matthew@seymour:~$ mv documents/filename archive

Notice that the filename is not included in the destination. The destination here must be an existing directory. If it is not, the file is renamed to the term used. Some examples will make this clear.

To rename a file that is in my current directory, I could use the following:

matthew@seymour:~$

Get Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.