How to Copy a Directory in Linux

onestop_databy:

Unix

This short tutorial teaches the easiest way on How to Copy a Directory in Linux – more specifically using the command line.

How to Copy a Directory in Linux Using the Terminal

First and foremost, most of the time something is copied on Unix using the command line, it is a single file that has a pretty straight-forward syntax:

$ cp <source_file> <destination_folder/>

Next, when copying a directory it is also simple, all you need to do is to add the recursive flag (-R) as shown below:

$ cp -R <source_folder> <destination_folder/>

Last but not least, in case more than a directory is desired to be copied you can use the following syntax:

$ cp -R <source_folder_1> <source_folder_2> ... <source_folder_N> <destination_folder/>

Obviously, the same tutorial can be used in any Unix based shell; it could be on your Linux based machine, MacOS, or even Microsoft Windows.

In case you want to learn this and other Unix command, please check this video class

More Resources