How to Copy Folder with Files to Another Folder in Linux?

Published in

on

If you know the basics of Linux command line then copying a file would be an easy task for you, all you need to do is just use the cp command with a file name and location.

In a Linux or a Unix environment, such action is called “Recursive”.

How to Copy a Directory in Linux?

In the Linux terms, a folder is called as a directory. So don’t get confused here!

Method #1

The option we’re looking for is -R.

cp -R path_to_source/ path_to_destination/
  • The -R means copy directories recursively.
  • If the destination doesn’t exist, it will be created.

Method #2

If you already in the directory you want to copy the use following command.

cp * path_to_destination/
  • The “*” symbol means everything inside the directory.

This is how we can copy the directory in Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *