RSYNC stands for remote synchronization, and it is a multi-purpose tool that is mainly used for transferring data from one location to another. Moreover, it is also used for data synchronization between different storage locations. These storage spaces can either be remote or local, i.e., you can even use this tool for synchronizing and transferring data to a remote location.
Here at LinuxAPT, we shall look into the options associated with Rsync and helpful examples to demonstrate its usage.
RSYNC Command Options
The RSYNC command in Linux offers different options that can be paired up with this command to produce the desired results.
To learn about all these options, all you need to do is to run the below command:
$ rsync --help
All the options of the RSYNC command, along with their detailed description, are stated in the help manual of this command.
The most commonly used options of the RSYNC command are:
- -a: This option is used for copying files recursively while preserving all the symbolic links, file permissions, timestamps, etc. It is known as the archive mode.
- -v: This option is used for displaying the details about the data being transferred during the execution of the RSYNC command. Moreover, it also displays a summary of the whole transaction at the end of the execution. This option stands for verbose.
- -h: This option is simply used for displaying the output of the RSYNC command in the human-readable format.
- –progress: This option is used for displaying the progress of the ongoing data transfer.
RSYNC Command Examples
1. Using the RSYNC Command for Listing the Contents of a Directory
Here, we want to use the RSYNC command for listing the contents of a directory with the RSYNC command:
$ rsync /home/system/Temp1/
Whenever we use the RSYNC command along with a directory without specifying any other options, then it works just like the "ls –l" command and displays the contents of the specified directory. In this particular example, we wanted to display the contents of the "Temp1" directory.
The contents of this directory will be displayed. This output not only presents the contents of the said directory but also specifies the access permissions of this directory as well as all of the files and sub-directories.
Similarly, you can use this command to display the contents of any directory of your system simply by replacing "/home/system/Temp1/" with the exact path of your particular directory.
2. Using the RSYNC Command for Copying the Contents of a Directory to Another
Now, we will use the RSYNC command for copying the contents of one directory to another by running the RSYNC command:
$ rsync –avh /home/system/Temp1/ /home/system/Temp2/
This command will simply copy all the contents of the "Temp1" directory to the "Temp2" directory. The "avh" options will display the output in human-readable format along with all the relevant information.
To confirm if the contents of the directory "Temp1" have been successfully copied to the directory "Temp2", we will display the contents of the "Temp2" directory by running the command:
$ rsync /home/system/Temp2/
The output will show that all the contents of the directory "Temp1" have been successfully copied to the directory "Temp2".
3. Using the RSYNC Command for Displaying the Copying Progress
Again, we will use the RSYNC command to display the progress while copying the contents from one directory to another by running the below command:
$ rsync –avh --progress /home/system/Temp1/ /home/system/Temp2/
The "progress" option is used for displaying the copying progress.
This option is particularly useful in situations where you are copying large files from one location to another that take up a reasonably long time.
[Need help in fixing Linux System issues ? We can help you. ]