mv (rename files)

This command is used to “move” (rename) files and directories. Invoke it like so:

mv -i SOURCE... DEST

This will move all SOURCE files and directories to DEST. The -i option (“interactive”) makes mv ask for permission before overwriting files. Leave out this option at your own risk! There may be multiple SOURCE files and directories, for example:

mv file1 file2 dir1 dir2

This will move file1, file2, and dir1 to dir2. mv is often used with wildcards, e.g.:

mv *.txt somedir

This will move all files ending in .txt to somedir. You should be aware of the fact that mv does not actually move data in most cases: it renames files. When you run mv file dir, for example, the content of file is not moved on your hard disk. The data stay where they are, but file is renamed to dir/file. Linux will only relocate the content of file if dir is on another file system, e.g. another disk partition. That's why mv can “move” a 5 gigabyte file in a fraction of a second.