We will show you, how to use rsync in Linux. Rsync is a file-copying tool which allows you to copy or synchronize files and directories on a local or remote system. It is fast and offers a large number of options. In this tutorial, we will show you how to use rsync on a Linux VPS.
These are some of the basic features of rsync:
– Rsync supports copying links, devices, owners, groups, and permissions.
– Rsync can use any transparent remote shell. For example, SSH or RSH.
– Rsync does not require super user privileges and can be used by regular system users.
Table of Contents
Install rsync in Linux
Rsync is installed by default with all our Linux VPS hosting plans. However, if you do not have rsync installed on your system, it is really simple to do that. First of all, log in to your server via SSH:
Install rsync on Ubuntu
If you like to install rsync on Ubuntu run the following commands:
# apt-get update && apt-get -y upgrade # apt-get -y install rsync
Install rsync on CentOS
If you like to install rsync on a CentOS VPS, run the following commands:
# yum -y update # yum -y install rsync
Once you have rsync installed on your system you can start using it. The basic syntax of rsync is the following:
# rsync option source destination
Rsync Man Page
Rsync has a lot of options which can be used to control every aspect of its behavior. For a full list of options available in rsync you can check the man page:
# man rsync
Here is a short list of some of the most commonly used options available in rsync:
-a, --archive archive mode -v, --verbose increase verbosity -z, --compress compress file data during the transfer -t, --times preserve modification times -p, --perms preserve permissions -h, --human-readable output numbers in a more human-readable format -l, --links copy symlinks as symlinks -e, --rsh=COMMAND specify the remote shell to use --numeric-ids don't map uid/gid values by user/group name --delete delete extraneous files from dest dirs
Rsync Example: Copy a directory from one location to another
To copy a directory from one location to another on your local system using rsync you can execute the following command:
# rsync -avh /tmp/foo /tmp/bar/
This command will copy the
/tmp/foo/ directory inside
/tmp/bar/. If you just like to copy the files inside
/tmp/bar/ then you can use the command:
# rsync -avh /tmp/foo/ /tmp/bar/
To copy a directory from your local machine to a remote machine you can use the same syntax, except that you will need to specify the destination address and the remote system user. For example, to copy the local
/tmp/foo/ directory inside
/tmp/bar/ on a remote machine with IP address
admin as username, you can use the following syntax:
# rsync -avh /tmp/foo firstname.lastname@example.org:/tmp/bar/
Of course you don’t have to use rsync in Linux if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to help you with using rsync on your server. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post, on how to use rsync in Linux, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.