Do you want to copy your directory or content to another location on Linux? Are you not sure how to achieve this? Do you want to know in how many ways you can do it? If yes, we are here with four different solutions for you.

Workable Solutions Step-by-step Troubleshooting
Copy Directories/Contents on Linux

Fix 1. Copy Directories on Linux...Full steps

Fix 2. Copy Directory Content on Linux...Full steps

Copy Directories to Remote Hosts

Fix 1. Use SCP Command...Full steps

Fix 2. Use the rsync Command...Full steps

Recover Deleted Directory in Linux Launch EaseUS Data Recovery Wizard...Full steps

Copying directories or content from one location to another on Linux is part of any system administrator's routine. If you have been using the Linux operating system for a while, you will know how important it is to keep your folders well structured in Linux. There are some situations where you may need to copy some directories or content on your system.

The best way to copy files is using the command line to achieve this. If we talk about Linux, there are different commands that you can use for copying files with cp and r sync. 

The cp command is one of the most common practices for copying files, whereas the rsync is for copying directories. 

The tutorial will help you get complete information about how you can easily copy directories and folders on a Linux system.

Linux Data Recovery Software Linux Delete Files and Directories

How to Copy Directories/Contents on Linux

Copying directories and contents on Linux is a routine task that anyone can easily accomplish by making a few commands perfectly. If you don't know what they are and how to use them perfectly, stay connected with us till the end to get absolute help.

1. Copy Directories on Linux

Copying directories on Linux is not as easy as in Windows. Linux is a complex platform where you need to make a few commands to let things happen conveniently. We are here with the detailed step-by-step process to conveniently help you copy directories on Linux.

Step 1. To copy a Linux directory, you must use the cp command with the -R option.  The command also needs the source and select the destination directories you plan to copy. 

$ cp -R

Step 2. Let's understand the same using an example. Consider that you are willing to copy the /Mkv directory into a backup folder named /mkv_backup. Keep in mind that the /mkv_backup folder is also there at the root of your filesystem.

Therefore for copying the /mkv directory to this backup folder, the command you need to use is:

$ cp -R /mkv /mkv_backup

Step 3.Once done, the /mkv folder will successfully be copied into the /mkv_backup. You have successfully copied one folder into another on Linux.

If you want to copy multiple directories in one go, then you need to choose the following format:

$ cp -R ...

All the source folders will be copied to the same destination folder and will be available inside it.

Copy Directories on Linux

2. Copy Directory Content on Linux

You can also copy directory content on Linux as we did with the directories. The only addition is that you need to use the wildcard character, so all the files are copied.

Step 1.To copy directory content on Linux, you can use the cp command with the -R option. Once done, you must specify the source directory carefully here and then provide the wildcard character.

$ cp -R /*

Step 2.If you are willing to copy content from the /mkv directory in the /mkv_backup folder, you can use the given command carefully.

$ cp -R /mkv/* /mkv_backup

Step 3. You can then use the LS command to list the content of the backup folder, and you will get to know the list of the files copied into the backup directory. 

$ ls -l /mkv_backup

copy directory content on Linux

How to Copy Directories to Remote Hosts

To copy directories to a remote host will not work with the usual CP command as we need to talk to two different machines. Instead, we need to use the SCP command or the RSYNC command. Unlike the CP command, these commands are built to work over a network, which only works on a system.

Method 1. Use SCP Command to Copy Directories

SCP Command to Copy Directories

You can use the SCP command to copy a directory on Linux to a remote location. You will also need to use the -r option for recursive and then execute the directory to be copied along with the destination. The command you have to use here is:

$ scp -r @ :

For example, if you have to copy the /mkv directory to a backup server located at in the /mkv_backup folder and to enable the same, the command you have to give is:

$ scp -r /mkv [email protected]:/mkv_backup/

You will need to use a Bash parameter substitution to copy the directory to your server's custom directory. 

$ scp -r /etc [email protected]:/mkv_backup/mkv_$(date +%F)

Method 2. Use the rsync Command to Copy Directories 

If you are willing to copy directories to a remote location using the rsync command, you will also need to specify the source folder and the remote destination.

If the rsync utility is unavailable on the server, you can install it using the sudo privileges. You can use the below-mentioned command to install the rsync tool.

$ sudo apt-get install rsync
$ sudo yum install rsync

You will also need to use the RSYNC command with the -r option for recursive and the -a option for all. The final command will look as below: 

$ rsync -ar @ :

Let's understand it using a real-world example:

Use the rsync Command to Copy Directories

Source: Copy the /mkv folder to the backup serve with IP address 192.168. 178,28/24.

Destination: Copy the above directory to the remote server's backup folder /mkv_backup.  

Assuming the user name is devuser, execute the following command:

$ rsync -ar /mkv [email protected]:/mkv_backup

You can select to copy the content of the /mkv/ directory here. You will append a wild character hereafter copying the directory.

$ rsync -ar /mkv/* [email protected]:/mkv_backup/

To complete the above process, you must introduce the current date and perform the directory backup here. The command you have to give here is:

$ rsync -ar /mkv/* [email protected]:/mkv_backup/etc_$(date +%F)

How to Recover Deleted Directory in Linux with Software

Copying directories or other content on Linux is not a big deal, but what if any of your important files are not available or deleted permanently? The situation seems to be quite annoying, right? 

If you are also going through this annoying situation, restoring directories, files, and folders in Linux is the best option. You can do that perfectly. As the demand for data recovery tools has increased rapidly in the last few years, it has also increased the number of service providers. 

EaseUS Data Recovery Wizard is one of the most acceptable data recovery options available in the marketplace that offers users the freedom of recovering lost files in Linux. Whether it is about MX Linux or Monaro, whether it is about Linux Mint, or it is about Ubuntu or Debian, it is a tool that goes well with all of the platforms successfully. 

Users can even use this tool to recover deleted files on their Windows PC without issues. It is a straightforward, easy go, and affordable data recovery wizard that hardly takes a few seconds to accomplish the process.

 Download for Win Recovery Rate 99.7%
 Download for Mac Trustpilot Rating 4.7

While the tool is officially available for Mac and Windows, it can also read the Linux directory structure. So if you lose a file on Linux, you can connect the drive to either  Windows or Mac and then use the software to recover deleted files in Linux.

If you are eager to know about this tool more, here we are, with the leading functions and highlights that will make things much more apparent to you.

  1. 1. Deleted Data Recovery
  2. 2. Flexible Scanning Modes
  3. 3. Preview Before Recovery
  4. 4. Free Remote Assistance

Steps of how to use EaseUS Data Recovery Wizard to recover your data are listed below:

Step 1. Install and Launch EaseUS Data Recovery Wizard on your Windows PC. Choose "Linux Recovery" on the left panel. 

Step 2. This software will detect your IP and Port automatically. You need to input the user name and password. If the IP address or Port is not right, you can correct it manually. Then, click "Connect Now". 

choose linux recovery

Step 3. After successfully connecting to your Linux device, EaseUS recovery software will start scanning the disk to find all lost and deleted files. When the scan process completes, click "Filter" > "Type" to specify lost file types.

choose the recovered data type

Step 4. You can preview the scanned files first. Then, select the target data and click the "Recover" button to restore lost files in Linux. 

recover windows 10 lost data

Final Words

So, Guys! It is all about copying the directory and contents to another location on Linux. Working on Linux is not the same as on Windows and macOS. You have to give different commands here to perform the various tasks conveniently. The guide has introduced you to four different methods for copying directories and contents from one location to another. 

 Download for Win Recovery Rate 99.7%
 Download for Mac Trustpilot Rating 4.7

Was This Page Helpful?

Updated by Daisy

Daisy is the Senior editor of the writing team for EaseUS. She has been working at EaseUS for over ten years, starting as a technical writer and moving on to being a team leader of the content group. As a professional author for over ten years, she writes a lot to help people overcome their tech troubles.

Read full bio

Approved by Evan Galasso

Evan Galasso is a digital forensics and data recovery engineer with over 10 years of experience in the field. He presents opinions on the current state of storage media, reverse engineering of storage systems and firmware, and electro-mechanical systems of SSDs and HDDs.

Read full bio