How to Copy a Directory in Linux

by:

Unix

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

1. 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/>

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

If you want to learn this and other Unix commands, please check this video class.

2. More Resources