How to Install and Use Rsync on Linux Servers

Rsync is a powerful tool used for syncing files between servers. It is a fast and efficient tool that can save you a lot of time and bandwidth when transferring large files. To install rsync on Ubuntu or Debian, use the following command:

sudo apt-get update

sudo apt-get install rsync

To install rsync on CentOS or Fedora, use the following command:

sudo yum install rsync

Once installed, you can use rsync to sync files between servers by running the following command:

rsync [options] source destination

For example, to sync the contents of the /var/www/html directory on server1 to the /var/www/html directory on server2, you would run the following command:

rsync -avz /var/www/html/ server2:/var/www/html/