Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the mv (move) command that allows you to rename files, move files to other places in the file system or do both of those things at the same time.
In its simplest form, we would use a command like this to rename a file:
Nothing will change about the file except for its name.
To move a file to another location (assuming you’re currently in the directory in which the file is located, you would do something like this.
This would move to the file to /tmp and rename it myfile.
File permissions and file ownership won’t be changed – just where the file is located.
You can move files into your home directory as easily as you can move files out of it. Here’s an example:
This command would move the specified file into your home directory (~ = the user’s home directory).
You can also move many files at once if you use wild cards. For example:
In that command, we moved all zipped files in the current directory into our backups folder.
That’s your Linux tip for the mv command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.