The fastest way to copy a folder in Linux depends on whether you use the command line or a graphical file manager

In the command line, you copy a folder using cp -r (the -r flag means "recursive," which tells cp to copy the folder and everything inside it). In a graphical file manager like Nautilus or Dolphin, you right-click the folder, select Copy, navigate to where you want it, and select Paste. Both methods work equally well — choose whichever matches how you normally work with files.

The command line approach is faster if you're copying many folders or moving between distant locations on your system. The file manager approach is more visual and requires less typing, which many people prefer for one-off copies.

Key Takeaways

  • The cp -r command copies a folder and all its contents; without the -r flag, cp will fail on folders.
  • The syntax is cp -r source_folder destination_folder, where source_folder is what you're copying and destination_folder is where it goes.
  • If you want to keep the same folder name, point to the destination directory only: cp -r my_folder /home/user/documents creates /home/user/documents/my_folder.
  • Right-click Copy and Paste in your file manager (Nautilus, Dolphin, Thunar) works the same way and requires no command line knowledge.
  • Use cp -r -i to be prompted before overwriting if a folder with that name already exists at the destination.

Copying a folder with cp -r at the command line

Open a terminal and navigate to the directory containing the folder you want to copy. If your folder is called my_project and you want to copy it to your Documents folder, type:

cp -r my_project /home/username/Documents

Replace username with your actual username. This creates a copy of my_project inside Documents with the same name. If you want to give the copy a different name, add the new name at the end:

cp -r my_project /home/username/Documents/my_project_backup

This copies my_project and names the copy my_project_backup. The -r flag is essential — without it, cp will return an error saying "omitting directory" because cp alone only copies files, not folders.

Using absolute and relative paths to specify locations

An absolute path starts from the root of your system and includes the full address: /home/username/Documents/my_folder. A relative path is shorter and assumes you're starting from your current location: if you're already in /home/username, you can type Documents/my_folder instead.

If you're in the same directory as the folder you want to copy, you can use a dot (.) to mean "the current directory." To copy my_project to your current location with a new name:

cp -r my_project ./my_project_copy

The ./ means "in the current directory." This is useful when you're already where you need to be and don't want to type out a long path.

Copying folders with a graphical file manager

Open your file manager (Nautilus on GNOME, Dolphin on KDE, Thunar on XFCE) and navigate to the folder you want to copy. Right-click it and select Copy from the menu. Then navigate to the destination folder, right-click in the empty space, and select Paste.

The file manager will copy the folder and all its contents to the new location with the same name. If a folder with that name already exists, most file managers will ask whether you want to replace it, merge it, or create a copy with a modified name like "my_project (copy)".

To rename the copy before pasting, right-click the destination folder after pasting and select Rename. This is simpler than typing a new name in the command line if you're not comfortable with terminal syntax.

Avoiding accidental overwrites with the -i flag

If you're copying a folder to a location where a folder with the same name might already exist, add the -i flag to be prompted before overwriting:

cp -r -i my_project /home/username/Documents

If Documents already contains a folder called my_project, the system will ask "overwrite '/home/username/Documents/my_project'?" and wait for you to type y (yes) or n (no). This prevents you from accidentally replacing an existing folder without realizing it.

The -i flag is especially useful when you're writing scripts or running commands you've used before, because it adds a safety checkpoint. In a file manager, this protection is built in — most will warn you before overwriting.

Copying folders to locations that need permission

If you're copying a folder to a system directory (like /usr or /opt) or to a folder owned by another user, you may need to use sudo to gain the necessary permissions:

sudo cp -r my_project /opt/my_project

The system will ask for your password. Use sudo only when you're certain you need it — copying to your home directory or Documents folder never requires it. If you use sudo unnecessarily, you may create files that you later cannot edit or delete without sudo again.

In a file manager, if you try to paste into a protected directory, the file manager will usually prompt you for your password or tell you that you don't have permission. Some file managers have an "Authenticate" button that handles this for you.

Checking that your copy was successful

After copying with the command line, you can verify the copy exists by listing the contents of the destination directory:

ls /home/username/Documents

You should see my_project listed. To check that the contents were copied correctly, you can compare the two folders using the diff command:

diff -r my_project /home/username/Documents/my_project

If the folders are identical, diff returns nothing. If there are differences, it lists them. In a file manager, you can simply open both folders side by side and visually confirm that the files and subfolders match.

Frequently Asked Questions

What's the difference between cp -r and cp -R?

Both work the same way in most Linux systems. The -r flag is more portable across different Unix-like systems, so it's the safer choice if you write scripts that might run on different machines. Use -r unless you have a specific reason not to.

Can I copy a folder to itself?

No — if you try to copy a folder into itself, you'll get an error like "cannot copy a directory into itself." This is a safety feature. If you want a copy in the same directory, give it a different name: cp -r my_project my_project_backup.

Does copying a folder also copy file permissions and ownership?

By default, cp copies the file contents but the new files are owned by you (the user running the command) and have default permissions. If you need to preserve the original ownership and permissions, use cp -r -p, where -p means "preserve." This is most useful when copying system files or backups.

What if the destination folder doesn't exist yet?

cp will create it for you. If you run cp -r my_project /home/username/new_location/my_project and new_location doesn't exist, the command will fail. You need to create new_location first using mkdir /home/username/new_location, then run the cp command.

Is there a way to see the progress while copying a large folder?

The basic cp command doesn't show progress. For large folders, you can use rsync instead: rsync -r --progress my_project /home/username/Documents. The --progress flag shows which files are being copied and how much has been transferred. rsync is slower than cp but more informative for big operations.