How to Copy Folder/Directory in Linux
Copy Folder/Directory in Linux
Folder or Directory contains a set of files. A directory can contain multiple files. The top-level main directory known as the root directory. Directories inside the root directory known as subdirectories. In this tutorial, you are going to learn how to Copy the Folder/Directory in Linux.
Copy Directory Using
The basic syntax to copy the directory by using cp command:
cp -arv SOURCE_DIRECTORY DEST_DIRECTORY
SOURCE_DIRECTORY: The source directory which you want to copy.
DEST_DIRECTORY: The destination directory where the SOURCE_DIRECTORY directory will be copied.
OPTIONS: Following are the options:
- -a: This option preserves the attributes like modification date,-time, ownership, file mode, etc.
- -r: This option will copy directory recursively.
- -v: It will verbose the output.
In the below example, it will copy the directory
demo and all the files inside the directory to the
demo2 directory. This process is done by preserving attributes with verbose output.
cp -arv demo demo2
The output should be:
Copy Directory using
You can copy files using
rsync command across the network at a faster speed than cp command.
rsync Command also archives the files and then copies it. So it reduces the size and time. This command is useful in transferring large files.
Following is the basic syntax to copy files using
rsync -azv SOURCE_DIRECTORY DEST_DIRECTORY
In the above command
-a (Archive Mode) option copies files recursively with all its permission information.
-z option compresses the data so the file sizes are reduced and will take less time. Option
-v will just verbose the output.
In the following example, all the files inside the directory
demo1 will be copied to the
demo3 directory. This process completes by preserving attributes with verbose output.
rsync -azv demo1 demo3
The output should be:
You have successfully learned How to Copy Folder/Directory in Linux. If you have any queries regarding this then please don’t forget to comment below.
How to Setup UFW firewall on Debian 9
How to install Git on Debian 9
How to Create Sudo User on CentOS
How to Install Laravel PHP Framework With Nginx on CentOS 7
How to Install PyCharm on CentOS 7
How to Install XAMPP on Fedora 29
How to Recursively Search all Files for a String in Linux
How to Install Nginx on Debian 10
How to install Java on Ubuntu 18.04
How to Install Anaconda on Linux Mint 19
How to Install Kodi on Fedora 29/30
How to Install R on CentOS 7