How to Copy Linux Directory and Contents (2023)

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 SolutionsStep-by-step Troubleshooting
Copy Directories/Contents on Linux

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

Fix 2. Copy Directory Contenton 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 LinuxLaunch 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.

How to Copy Linux Directory and Contents (1)

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

How to Copy Linux Directory and Contents (2)

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

How to Copy Linux Directory and Contents (3)

You can use theSCPcommand 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 [emailprotected]:/mkv_backup/

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

$ scp -r /etc [emailprotected]:/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:

How to Copy Linux Directory and Contents (4)

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 isdevuser, execute the following command:

$ rsync -ar /mkv [emailprotected]:/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/* [emailprotected]:/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/* [emailprotected]:/mkv_backup/etc_$(date +%F)

How to Recover Deleted Directory in Linux withSoftware

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 toinput the user name and password. If the IP address or Port is not right, you can correct it manually. Then, click "Connect Now".

How to Copy Linux Directory and Contents (5)

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

How to Copy Linux Directory and Contents (6)

Step 4.You can preview the scannedfiles first. Then, select the targetdataand click the "Recover" button to restore lost files in Linux.

How to Copy Linux Directory and Contents (7)

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

Top Articles
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated: 01/09/2023

Views: 6165

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.