Linux copy directory
To copy a directory in Linux, you can use the
cp command with the
-r option, which stands for “recursive”. This option tells the
cp command to copy the directory and all of its contents, including any subdirectories.
Here’s the basic syntax for copying a directory:
cp -r /path/to/source/directory /path/to/destination/directory
For example, if you wanted to copy a directory named “my_folder” from your home directory to a directory called “backup” in your Documents directory, you would run the following command:
cp -r ~/my_folder ~/Documents/backup/
This would copy the entire “my_folder” directory and its contents to the “backup” directory in your Documents folder.
Note that the
cp command will overwrite any files in the destination directory that have the same name as files in the source directory.
Leave a Reply