Linux and Unix Copy files

To copy a directory with all subdirectories and files, use the cp command. Below is an example command of how you would use the cp command to copy files. Additional information about this command and other examples are available through the above cp link.

cp -r /home/hope/files/* /home/hope/backup

In the example above, the cp command would copy all files, directories, and subdirectories in the /home/hope/files directory to the /home/hope/backup directory.

or

Copy a folder called /tmp/conf to /tmp/backup:

cp -avr /tmp/conf/ /tmp/backup

-a : Preserve the specified attributes such as directory an file mode, ownership, timestamps, if possible additional attributes: context, links, xattr, all.

-v : Explain what is being done.

-r : Copy directories recursively. Example

You may also like...