How to copy directories?

QuestionsQuestions8 SkillsProBasic Files OperationsAug, 29 2025
0118

To copy directories in Unix-like operating systems, you need to use the cp command with the -r (recursive) option. This allows you to copy the directory and all its contents. Here's how to do it:

Copying a Directory

cp -r source_directory/ destination_directory/
  • source_directory/: This is the directory you want to copy.
  • destination_directory/: This is the target directory where you want to copy the source directory.

Example

To copy a directory named my_folder to a new directory called my_folder_backup, you would use:

cp -r my_folder/ my_folder_backup/

This command will create a copy of my_folder and all its contents in my_folder_backup.

If you have any more questions or need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!