How to Move Files in Ubuntu: A Complete Guide to Using GUI and Terminal Commands

1. Introduction

Ubuntu is a Linux distribution widely supported by users for its ease of use and flexibility. For developers and system administrators in particular, file management is one of the tasks performed on a daily basis.

This article explains how to move files in an Ubuntu environment for both beginners and intermediate users. By covering both the GUI (Graphical User Interface) and CLI (Command Line Interface), you can choose the method that best suits your skills and preferences.

By reading this article, you will learn the following skills:

  • Simple file movement using the GUI
  • Flexible operations using the mv command
  • Important notes on permissions and errors, and how to deal with them

Now, let’s take a closer look at how to move files in Ubuntu.

2. Moving Files Using the GUI

Ubuntu provides GUI tools that allow you to perform file operations intuitively. In this section, we introduce how to move files using the default file manager, “Files.”

2.1 How to Launch the File Manager

The Ubuntu file manager is called “Files.” Follow these steps to launch it:

  1. Click the “Files” icon on the left-side activity bar.
  2. Alternatively, press the “Super key” (equivalent to the Windows key), type “files” in the search bar, and press Enter.

This opens the file manager, allowing you to visually navigate and operate directories.

2.2 Moving Files via Drag & Drop

The easiest way to move files or folders is by using drag and drop. Follow the steps below:

  1. Select the file or folder you want to move.
  2. Open the destination folder in another window or in the same window.
  3. Drag the selected file and drop it into the destination.

The selected item will be moved to the new location.

2.3 Moving Files via Copy & Paste

Another useful method is using the copy-and-paste feature. Follow these steps:

  1. Right-click the file you want to move and select “Cut.”
  2. Open the destination folder, right-click, and select “Paste.”

Shortcut keys are also available:

  • Cut: Ctrl + X
  • Copy: Ctrl + C
  • Paste: Ctrl + V

This method is efficient for users who prefer keyboard operations.

3. Moving Files Using the Terminal

In Ubuntu, you can efficiently move files and directories using the terminal. This section explains how to use the mv command and its useful options.

3.1 Basics of the mv Command

To move files in the terminal, use the mv command. It stands for “move,” but it can also be used to rename files.

Basic syntax:

mv [options] source destination
  • source: The path of the file or folder you want to move
  • destination: The target path

Example:

mv file1.txt /home/user/Documents/

This command moves file1.txt from the current directory to the Documents folder.

3.2 How to Move Files

Move a file to another folder:

mv example.txt /home/user/Desktop/

This command moves example.txt to the Desktop.

Move multiple files at once:

mv file1.txt file2.txt /home/user/Documents/

This moves both files into the Documents folder.

3.3 Moving Directories

You can also move directories (folders) in the same way.

Move a folder:

mv folder1 /home/user/Documents/

Move all contents of a folder:

mv folder1/* /home/user/Documents/

3.4 Renaming Files or Directories

Rename a file:

mv oldname.txt newname.txt

Rename a folder:

mv oldfolder newfolder

3.5 Useful mv Options

-i Option (Prompt Before Overwriting)

mv -i file1.txt /home/user/Documents/

-f Option (Force Overwrite)

mv -f file1.txt /home/user/Documents/

-n Option (Do Not Overwrite)

mv -n file1.txt /home/user/Documents/

-v Option (Verbose Output)

mv -v file1.txt /home/user/Documents/

By combining these options, you can manage files safely and efficiently.

4. Important Notes and Best Practices

When moving files in Ubuntu, be aware of overwrite risks, permission issues, and other potential problems. This section outlines tips for avoiding errors and working more safely.

4.1 Overwrite Risks and Prevention

Risk of overwriting during file movement:
If a file with the same name already exists in the destination, mv may overwrite it without warning, causing data loss.

Prevention:

  1. Move with overwrite confirmation (-i option)
mv -i file1.txt /home/user/Documents/
  1. Disable overwriting (-n option)
mv -n file1.txt /home/user/Documents/
  1. Create a backup before moving
cp file1.txt file1_backup.txt

4.2 Permission Considerations

Permission errors:
If you attempt to move system files or another user’s files, you may encounter the error “Permission denied.”

Solutions:

  1. Check permissions
ls -l file1.txt
  1. Change permissions
sudo chmod 755 file1.txt
  1. Run with administrator rights
sudo mv file1.txt /etc/config/

4.3 Handling Symbolic Links

A symbolic link is a reference (shortcut) to a file or directory. When moving a symbolic link using mv, only the link itself is moved.

Be careful with links:

mv link1.txt /home/user/Documents/
  • Check the link target if you want to move actual files instead
ls -l link1.txt
  • Copy the target file manually if needed
cp /path/to/target.txt /home/user/Documents/

4.4 Moving Files Across Filesystems

Moving between partitions or devices:
When moving files across different filesystems, mv performs a “copy and delete” operation. This may take longer with large datasets.

Solutions:

  1. Copy and confirm, then delete
cp -r folder1 /media/usb-drive/
rm -r folder1
  1. Use rsync for efficient transfers
rsync -av --remove-source-files folder1/ /media/usb-drive/

5. Summary

This article explained how to move files in Ubuntu using both the GUI and the CLI. Each method has its own advantages and can be used based on your proficiency level.

Key Takeaways

  1. Moving files using the GUI:
  • Drag & drop or copy & paste enables simple and visual operations.
  • Ideal for beginners due to its intuitive workflow.
  1. Moving files using the Terminal (CLI):
  • The mv command enables advanced and bulk operations.
  • Options such as -i, -f, -n, and -v minimize risks.
  1. Important notes and best practices:
  • Use backup strategies or overwrite options to prevent data loss.
  • Be aware of permission errors, symbolic links, and filesystem differences.

Which Method Should You Choose?

  • Beginners: The GUI file manager is recommended for its simplicity and low error risk.
  • Intermediate users: The terminal offers faster operations, batch processing, and more control.

Next Steps

Apply this knowledge to develop more advanced file management skills:

  • Create automation scripts:
    Use mv in batch scripts to streamline file handling.
  • Integrate with cloud storage:
    Connect Ubuntu with Google Drive or Dropbox for remote management.
  • Use shell scripts:
    Automate regular tasks and scheduled backups.

Final Thoughts

Ubuntu’s file management offers both flexibility and efficiency through the combination of GUI and CLI tools. Use the methods introduced here to find the best workflow for your needs.

We will continue sharing useful Ubuntu and Linux-related tips. Stay tuned for more!

年収訴求