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 Install Sublime Text 3 on Ubuntu 18.04
How to Install Notepad++ on Ubuntu 18.04
How to Add Swap Space on CentOS 7
How to Install PyCharm on Debian 9
How to Install Kodi on Ubuntu 18.04
How to install PHP 7.2 on Debian 9
How to Change or Rename Username and UID in Linux
How to Install Sublime Text 3 on Debian 10
How to Install Composer on CentOS 8
How to Install Google Earth on Linux Mint 19
How to install Pip on Debian 9
How to Change Hostname on Ubuntu 18.04