7.1 Advanced Directory and File Management Using the Command Line
7.1.2 Copying directories
Use the cp -r (recursive) command to copy a directory and its contents to another directory. If the destination directory does not exist, it is created. Without the -r option, files and subdirectories contained within a directory will not be copied. When used with the -i option, cp prompts for verification before overwriting an existing file.
Command Format:
cp -r[i] source_directory(s) destination_directory

Copying a Directory within the Same Directory
The
cp -r command can be used to copy a directory and all of its contents to a new directory in the current directory. You must use the -r option to copy directories. Figure shows copying the dir3 directory to a new directory named ski.places without using the -r option and demonstrates the error that results. The last example shows the proper use of the  cp -r command to copy a directory. Notice that the dir3 directory is being copied to a new directory named ski.places which has an extension of 5 characters. It is permissible to have multiple extensions with UNIX directory names.

Copying a Directory to Another Directory
Figure demonstrates how to copy a directory to another directory that is not in the current directory. In the example, the planets directory is copied to dir1/constellation using a relative pathname. The .. (two dots) moves up one directory and then down to the
dir1 directory. The second example copies two directories at the same time; dir1 and ski.places to the absolute pathname of the /tmp directory.

Interactive Media Activity (Flash, 95 kB)
  Copying Directories

In this media activity, you are logged in as user2 and your current working directory is: /home/user2/dir3. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and type the commands that would accomplish the requested objectives. 
Note: Be sure to press enter after each one. Click on step 1 to begin.
 

Lab Activity (Adobe Acrobat Reader, 48 kB)
  Copying Files and Directories

In this lab, you will perform more advanced file and directory management tasks using the command line interface and the cp (copy) command.