Phone :  +370 (5) 204-1903
Email :  sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to Move Files in Linux

How to Move Files in Linux

Are you new to Linux and trying to figure out how to move files around? It can initially seem intimidating, but don't worry - we can help! This article will review the basics of moving files in Linux. We'll cover how to use the mv command, how to move files from one directory to another, and how to move multiple files at once. Once you understand the basics, you can move files in Linux like a pro!

Linux Tutorial Apr 26, 23 by Nisal N 4 min Read
How to Move Files in Linux

List of content you will read in this article:

How to Move Files in Linux

First, let’s review something together, what does moving files mean? It means: To cut a file from the first location and paste it into another one. When you move a file, the file will get deleted from the previous place.

Now, we will focus on two different ways you can move your files.

  • With GUI or Graphical User Interface
  • With the terminal or the command-line tool

Moving files by using GUI

There are several GUL tools available for the Linux operating system. Nautilus is one of them that’s wildly used due to its flexibility. To transfer a file, follow the steps below:

  1. Open the file manager
  2. Choose your file and right-click on it
  3. Click on the ‘Move to’ option
  4. Select the new location
  5. Then press the ‘Select’ option

Moving files in the Linux terminal

Use the mv command to move your files from the source to the destination.

How to use the mv command and examples

The Linux command mv is a convenient way to move files and directories from one place to another. To use the 'mv' command, open the terminal and type in 'mv' followed by two arguments—the source and the destination of the file or directory you're moving.

For example, if you wanted to move a file named 'myfile.txt' from your home folder into the Documents folder, you would type the command below:

Syntax: mv myfile.txt Documents/myfile.txt

Example: Moving a folder into the directory

As mentioned above, you can move a file from one location to another. Let’s take a look at another example. To move the ‘Example.txt’ file to the ‘Example’ folder, follow the steps below:

  1. Move the ‘Example’ folder into the ‘Downloads’ directory.
  2. Type ‘Is’ to confirm.

Example: Moving several files at once

When you want to move several files simultaneously, the mv command will consider the last directory as the destination. In this case, you can move your files to the “Downloads” directory and follow the steps below:

  1. Open the “Documents” directory, as all of your files are placed there
  2. Type the ‘Is’ command
  3. Then press enter

Mv’s command options

Mv’s command options include:

mv -f

This command is used to force a move by overwriting the destination file.

mv -i

This command prompts you to confirm whether the file will overwrite the file in your destination.

mv -v

This command is used to show the progress of files being copied.

Conclusion

  • Moving files is the act of cutting them and pasting them into another folder.
  • Since moving a file in Linux isn’t as easy as moving on Windows or macOS, so you must be fluent with its commands.
  • Your two methods for moving files in Linux are GUI and the Terminal.

By purchasing a cheap linux vps, you can have full control over your hosting environment and tailor it to your specific needs, allowing you to optimize performance and ensure reliable uptime for your applications or website.

FAQ

What is the command to move a file in Linux? 

The command for moving a file in Linux is "mv".

How do you move multiple files in Linux?

You can move multiple files in Linux using the command "mv" followed by a list of files or directories you want to move and their destination. 

Is it possible to overwrite existing files when moving them to Linux?

Yes, it is possible to overwrite existing files using the "mv" command in Linux. To do so, use the "-f" flag after the command.

How do you move files and directories with the same name from one location to another? 

To move files and directories with the same name from one location to another, you should use the "-i" flag after the "mv" command, which will prompt you if you want to overwrite an existing file/directory or not.

People also read: 

How to unzip files in Linux?

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment