In UNIX and UNIX-like systems, mv (short for move) is a command used to move one or more files or directories from one location to another. The user executing the command must have write permissions for both the current directory and the destination directory for the argument to work, as mv changes the contents of both directories.

In some UNIX iteration, the commands cp, ln, and mv (copy, link, and move) are linked together at the binary level, giving the user mover leverage in deciding how to manipulate the file and/or directory. As with the command rm, switches like -i and -f are perfectly acceptable.


MV LINUX Nuts and Bolts

i switch

The -i switch will force mv to verify each mv ahead of time, but this becomes tedious with large batches of files for obvious reasons. Mostly, the use of rm is pretty straightforward, and, say, you wanted to move a file called playlist. Then just type in mv playlist, and - poof - it is gone out of one folder and appears in the destination.

Perhaps you were not sure about moving playlist2, however, so you would execute to command, rm -i playlist2 to prompt you to make sure moving the file is ok, and it will ask you to confirm your choice by typing “yes” three separate times.

Also, like rm, mv LINUX accepts the -f (force) switch, which will override permissions. But mv is much more powerful than being able to just move files, as it can rename and even back up file given the correct switch is called when the command is executed.



LINUX MV: Proceed with Caution

Terminal data

Write-protected files are your friend, and mv will prompt you before deleting them. You must answer yes three different time before they will be removed, and, also, a write-protected directory is even more difficult to move by design.

The command mv, like rm, works silently, and will not return a comment unless there is an error or necessary prompt. Unlike rm, though, it is inherently adept at dealing with folders, and it will handle any sort of file, folder, or directory on your HDD with ease.

Beware though, because unless you use the correct switch the data in the folder you are moving from could be deleted by the time mv is done copying over information. Take, for example, the following scenario of renaming /home/jojo/thingamajig to /home/jojo/thingamajig2 in the same folder.

Sure, you could say, just right-click and rename it, but let’s use the command-line. In terms of mv, that would be written as mv /home/jojo/thingamajig /home/jojo/thingamajig2, and, in terms of what LINUX understands you would be telling it to take the data from a file called thingamajig and move it to a new folder called thingamajig2. This would leave thingamajig empty with no data, and you could use rm -r to remove it.



MV LINUX Requires Brain Power

MV LINUX Requires Brain Power

That may seem like an overcomplicated process when you consider that, through the GUI, you can just drag and drop, but, nevertheless, that is what goes on under the LINUX hood. One blog, further posits that we, as users, have gotten into the habit of taking for granted many of the simple tasks that computers carry out on a daily basis.

Moving from Windows to LINUX or MAC OS to LINUX, or, even in some cases, from Windows to MAC OS can make you more aware of just how complicated computer files systems actually are, and using mv LINUX to move files is one of the most common conundrums for most new free-source OS users.

Beyond helping you keep in touch with the “old school” side of computers, there is a fair bit of raw power to access, as UNIX and UNIX-like systems use, essentially the same command-line brain under the hood. And the command arguments for mv LINUX are very good examples.

The mv LINUX command is very simple. It moves stuff. It moves stuff by moving stuff, and it moves stuff by renaming it. The power of mv LINUX is multiplied when you consider the use of wildcards. Take, for example, the following scenario, thank, in part to Computer Hope:

mv ~/Downloads/*.png /home/jojo/Documents/

Remember, too that moving up a level is easy by implementing the ../ call. So moving those .png files from /home/jojo/Documents/ to /home/jojo is a snap with the mv /home/jojo/Documents/ ../ argument.

Please note that if a file exists in the folder you are moving to with the same name as the file you are moving, it will be deleted unless you use the -b (backup switch).

There. Without too much effort you just moved all files with the .png extension from the Downloads folder to jojo’s Documents folder to his home folder with two single lines of code. Now that is power. And is more fun than dragging around files, don’t you think?

MV LINUX Via the GUI

MV LINUX Via the GUI

By this time, you already know there are about as many flavors of the LINUX GUI as there are flavors of ice cream at the local scoop shop.

On top of that, there are a lot of file managers you can use. And with them comes some popular file managers like KDE’s Dolphin or Gnome’s Nautilus. Both are powerful and flexible graphical interpretations of command line arguments.

They may not be as powerful as the simplicity of the command-line, but they are darn easy to use and just as effective. By and far, the protocol is the same but the following example was taken from an Ubuntu installation running Nautilus:

  • 1
    Open the file manager by clicking it.
  • 2
    Locate the file you intend to move, then right-click it.
  • 3
    A pop-up will appear, and you should choose the “Move To” option.
  • 4
    A follow-up window will open and need to navigate to the new destination.
  • 5
    Once you are there select that file, and you are done.


You can also move files to the Trash, copy, and more. Nautilus will function as a drag and drop manager as well, and you can avoid that second pop-up window, granted the destination is listed in the common places section of your file manager. If it is not, no worries, just pop open that second window, and you are good to go.

Single files, multiple files, it is pretty much the same argument under the hood, plus or minus a few characters. But LINUX file manager like Nautilus will save you the pain of having to learn the LINUX command line all at once. Just don’t rely on it too heavily, lest you miss the point of running mv LINUX and other commands in the first place.


LINUX MV Wrap-up

data

It should be apparent to you now, the mv LINUX is a powerful, if not basic, command that as important as rm, cp, ln, and other simple arguments. Plus, moving files about and renaming name is one of the most integral elements of any OS.

We've only touched the tip of the iceberg as far as examples of mv, so to read all about it, as always, just type man mv at the command-line for a better grasp on what it can do. Just remember that mv works with single files, multiple files, and directories. Plus, you can rename files, folders, and directories with it.

As for this blog, we hope we have at least perked your interest in using the command line to perform some of the most basic tasks on your computer. We have touched many of the command line options this tool offers. But, as with all UNIX and UNIX-liked command, they are flexible, can understand multiple switches, can be piped, and can be combined with other commands.

Hands working in the laptop

The possibilities with mv LINUX run quite deep, and it all depends how much you want to learn the command-line and use it regularly. Because, if you want to retain any of this knowledge, you have to use it - or it will disappear, and you will be right back in this tutorial (not that that is a bad thing).

But, if you practice and start with the basic commands, the command-line won’t seem so intimidating, you will want to practice more, and you will be well on your way to using piped arguments in no time at all.

So, start practicing now, move some files around, copy them, link them, and rm the old ones. Once you get going, you’ll wonder why they made the GUI at all.