Learning

Linux for Starters: Your Guide to Linux – Manipulating Files – Part 13

Last Updated on May 22, 2022

mv

mv is a command to move or rename files and directories. It either moves one or more files to a different directory, or it will rename a file or directory.

With the command below we are renaming the filename source to the filename target. If target does not exist then source is renamed target. If target exists its contents are silently replaced with the contents of source.

$ mv source target

Let’s move 3 files into a different directory, keeping the filenames:

$ mv source1 source2 source3 target_directory

If we want to prevent accidentally overwriting files, we can prompt for confirmation before overwriting existing files, regardless of file permissions with:

$ mv -i source target

Here’s a few other examples of common mv usage.

Do not overwrite existing files at the target:

$ mv -n source target

Move files in verbose mode, showing files after they are moved:

$ mv -v source target

Like cp, the power of mv is enhanced with wildcards. For example, let’s suppose we want to move image files (.jpg and .png) to our Pictures directory.

$ mv *.jpg *.png ~/Pictures/

Page 3 – rm

Pages in this article:
Page 1 – cp
Page 2 – mv
Page 3 – rm
Page 4 – mkdir


All articles in this series:

Linux For Starters: Your Guide to Linux
1What is Linux? Why use Linux? What do I need?
2Choose a Linux distribution meeting your specific needs and requirements.
3Make a bootable Ubuntu USB stick in Windows.
4We show you how to install Ubuntu 21.04 on your hard disk.
5Things to do after installing Ubuntu.
6Navigating your way around the Desktop.
7Updating the system, install new software.
8Open source replacements for proprietary Windows desktop software.
9Get started with the power and flexibility of the terminal.
10We cover the basics of files and permissions.
11Getting help from your system.
12Learn all about the file system.
13Manipulating files from the shell.
14Maintain your system with these simple tips.
15Managing users on your system.
16Explore different desktops to GNOME 3.
17Gaming on Linux.
18Protect your privacy with this guide.
19Access the Windows desktop from Linux using a remote desktop client.
20Set up a virtual machine running Ubuntu as the host and openSUSE as the guest.
21Wine lets you run Windows programs on Linux without emulation.
22Extend your GNOME desktop with extensions and themes.
XUseful Linux commands.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
D Watson
D Watson
3 years ago

Thanks. How many parts will this guide be?