{"id":1497,"date":"2025-05-19T23:00:53","date_gmt":"2025-05-19T23:00:53","guid":{"rendered":"https:\/\/b2bhostingclub.com\/blog\/?p=1497"},"modified":"2026-02-04T14:14:37","modified_gmt":"2026-02-04T14:14:37","slug":"use-of-rsync-command-in-linux-with-example","status":"publish","type":"post","link":"https:\/\/b2bhostingclub.com\/blog\/use-of-rsync-command-in-linux-with-example\/","title":{"rendered":"Use of Rsync Command in Linux with Example"},"content":{"rendered":"<h1>What is Rsync Command In Linux?<\/h1>\n<p>The Rsync command in Linux is mostly used to copy and synchronize files and directories remotely along with copying them locally in Linux\/Unix system.<\/p>\n<p>With the help of the\u00a0<strong>rsync\u00a0<\/strong>command, you can easily copy and synchronize your data remotely and locally across the directories, disks, and networks. You can also perform data backups, and mirror between two Linux machines.<\/p>\n<p>In this article, we\u2019re going to walk you through the deep analysis of\u00a0the<strong>\u00a0rsync\u00a0<\/strong>command with practical examples so you never have to Google anything about the rsync command.<\/p>\n<p>However, if you\u2019re new to the Linux field, you should first learn the\u00a0basic Linux Commands, and then you can use the rsync command more efficiently.<\/p>\n<hr \/>\n<h1>Advantages of Rsync Command in Linux<\/h1>\n<p>Below are some of the major advantages of using the rsync command;<\/p>\n<ul>\n<li>\n<blockquote><p>No need to have root privileges to run the rsync command. You can easily use it without root access.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p>it\u2019s the most effective way to sync and copy files from or to a remote server.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p>You can copy links, devices, owners, groups, and permissions which is rare.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p>It\u2019s faster than\u00a0<strong>SCP (Secure Copy)\u00a0<\/strong>method as it uses a remote-update protocol to transfer files between server to system.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p>It\u00a0consumes less bandwidth in comparison with any other copying method because rsync uses compression and decompression while sending or\/and receiving data\u00a0from\u00a0both ends.<\/p><\/blockquote>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>How to Use the Rsync Command<\/h3>\n<pre><em># rsync options source destination\r\n<\/em><\/pre>\n<p><em>Some useful arguments you can use with\u00a0the<strong>\u00a0rsync\u00a0<\/strong>command;<\/em><\/p>\n<ul>\n<li>\n<blockquote><p><strong>-r<\/strong>\u00a0: copies data recursively (but don\u2019t preserve timestamps and permission while transferring data.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p><strong>-a<\/strong>\u00a0: archive mode, which allows copying files recursively and it also preserves symbolic links, file permissions, user &amp; group ownerships, and timestamps.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p><strong>-z<\/strong>\u00a0: compress file data.<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p><strong>-v<\/strong>\u00a0: verbose<\/p><\/blockquote>\n<\/li>\n<li>\n<blockquote><p><strong>-h<\/strong>\u00a0: human-readable, output numbers in a human-readable format.<\/p><\/blockquote>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>How to Install Rsync In Linux System?<\/h3>\n<p>Installation of the\u00a0<strong>Rsync\u00a0<\/strong>command is fairly simple. You can easily install it by following the below command.<\/p>\n<pre><em>$ sudo apt-get install rsync   [On Debian\/Ubuntu &amp; Mint] \r\n$ pacman -S rsync              [On Arch Linux]\r\n$ emerge sys-apps\/rsync        [On Gentoo]\r\n$ sudo dnf install rsync       [On Fedora\/CentOS\/RHEL and Rocky Linux\/AlmaLinux]\r\n$ sudo zypper install rsync    [On openSUSE]<\/em><\/pre>\n<h1>Copy\/Sync Files &amp; Directories Locally<\/h1>\n<h3>Copy\/Sync a File on a Local Computer<\/h3>\n<p>Use the following command to Sync\/Copy a file locally from one location to another.<\/p>\n<pre><em>[getintod@server55 public_html]$ rsync xmlrpc.php \/home\/getintod\/ (Execute command from public_html PWD)\r\n[getintod@server55 public_html]$ cd \/home\/getintod\/               (Jump to the directory where you copied)\r\n[getintod@server55 ~]$ ls                                         (List the contents)<\/em>\r\n<em>access-logs file2.php newfile2.php public_ftp var<\/em>\r\n<em>backup getintod newfile3.php public_html wp-login.php<\/em>\r\n<em>cpanel3-skel home.php newfile.php renamed.htaccess www<\/em>\r\n<em>etc logs ocartdata ssl <strong>xmlrpc.php                                 <\/strong>(File Successfully Copied &amp; Scyned)<\/em>\r\n<em>example1.php mail perl test.php<\/em>\r\n<em>example.php newfile1.php perl5 tmp<\/em>\r\n<em>[getintod@server55 ~]$<\/em><\/pre>\n<h3>Copy\/Sync a Directory on a Local Computer<\/h3>\n<p>Use the below command to transfer or sync all the files of a directory to a different directory on the same machine. In the below example,\u00a0<em>\/home\/getintod\/backup\u00a0<\/em>directory contains several files and I want to copy all the files present inside the\u00a0<em><strong>backup\u00a0<\/strong><\/em>directory to another directory named\u00a0<em><strong>etc.<\/strong><\/em><\/p>\n<pre><em>[getintod@server55 ~]$ rsync -avzh \/home\/getintod\/backup \/home\/getintod\/etc\/       (Transfer every files from <strong>backup <\/strong>directory to <strong>etc <\/strong>directory)<\/em>\r\n<em>sending incremental file list<\/em>\r\n<em>backup\/<\/em>\r\n<em>backup\/boot.html<\/em>\r\n<em>backup\/homepage.php.<\/em>\r\n<em>backup\/index.html<\/em>\r\n<em>backup\/new.tar<\/em>\r\n<em>backup\/newfile.php\r\n<\/em>\r\n<em>sent 376 bytes received 115 bytes 982.00 bytes\/sec<\/em>\r\n<em>total size is 0 speedup is 0.00<\/em><\/pre>\n<figure id=\"attachment_10281\" class=\"wp-caption aligncenter\" aria-describedby=\"caption-attachment-10281\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-10281 entered litespeed-loaded\" src=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories.png\" sizes=\"(max-width: 825px) 100vw, 825px\" srcset=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories.png 825w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories-300x96.png 300w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories-768x246.png 768w\" alt=\"Copy Sync files between directories\" width=\"825\" height=\"264\" data-lazyloaded=\"1\" data-placeholder-resp=\"825x264\" data-src=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories.png\" data-srcset=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories.png 825w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories-300x96.png 300w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Sync-files-between-directories-768x246.png 768w\" data-sizes=\"(max-width: 825px) 100vw, 825px\" data-ll-status=\"loaded\" \/><figcaption id=\"caption-attachment-10281\" class=\"wp-caption-text\">Sync files between local directories<\/figcaption><\/figure>\n<h1>Copy\/Sync Files &amp; Directories to or from a Remote Server<\/h1>\n<h3>Copy a Directory from a Local Server to a Remote Server<\/h3>\n<p>You can simply use the below command to copy\/sync a file from a remote server. In the below example, I\u2019m having a couple of files inside the\u00a0<em><strong>etc\u00a0<\/strong><\/em>directory of my local server, and want to transfer all its content to the remote server. Type the following command to send a directory from a local server to a remote server.<\/p>\n<p><em>Note: Do not forget to change the\u00a0<strong>path\u00a0<\/strong>and\u00a0<strong>IP Address\u00a0<\/strong>with yours. Don\u2019t just copy-paste the command. It won\u2019t work.<\/em><\/p>\n<pre><em>[getintod@server55 ~]$ <\/em><em>rsync -avzh \/home\/getintod\/etc root@123.456.78.90:\/root\/<\/em><\/pre>\n<figure id=\"attachment_10282\" class=\"wp-caption aligncenter\" aria-describedby=\"caption-attachment-10282\"><img decoding=\"async\" class=\"size-full wp-image-10282 entered litespeed-loaded\" src=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote.png\" sizes=\"(max-width: 809px) 100vw, 809px\" srcset=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote.png 809w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-300x148.png 300w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-768x378.png 768w\" alt=\"Copy Files from local to remote\" width=\"809\" height=\"398\" data-lazyloaded=\"1\" data-placeholder-resp=\"809x398\" data-src=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote.png\" data-srcset=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote.png 809w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-300x148.png 300w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-768x378.png 768w\" data-sizes=\"(max-width: 809px) 100vw, 809px\" data-ll-status=\"loaded\" \/><figcaption id=\"caption-attachment-10282\" class=\"wp-caption-text\">Copy Files from local to remote<\/figcaption><\/figure>\n<h3>Copy\/Sync a Remote Directory to a Local Machine<\/h3>\n<pre><em>[getintod@server55 ~]$ rsync -avzh root@79.143.188.36:\/root\/backup \/home\/getintod\/etc\/<\/em>\r\n<em>root@79.143.188.36's password:<\/em>\r\n<em>receiving incremental file list\r\n\r\n<\/em><em>sent 25 bytes received 186 bytes 24.82 bytes\/sec<\/em>\r\n<em>total size is 0 speedup is 0.00<\/em><\/pre>\n<figure id=\"attachment_10285\" class=\"wp-caption aligncenter\" aria-describedby=\"caption-attachment-10285\"><img decoding=\"async\" class=\"size-large wp-image-10285 entered litespeed-loaded\" src=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-1024x146.png\" sizes=\"(max-width: 678px) 100vw, 678px\" srcset=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-1024x146.png 1024w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-300x43.png 300w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-768x109.png 768w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1.png 1061w\" alt=\"Copy Files From Remote Server To Local\" width=\"678\" height=\"97\" data-lazyloaded=\"1\" data-placeholder-resp=\"678x97\" data-src=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-1024x146.png\" data-srcset=\"https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-1024x146.png 1024w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-300x43.png 300w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1-768x109.png 768w, https:\/\/blog.redserverhost.com\/wp-content\/uploads\/2022\/04\/Copy-Files-from-local-to-remote-1.png 1061w\" data-sizes=\"(max-width: 678px) 100vw, 678px\" data-ll-status=\"loaded\" \/><figcaption id=\"caption-attachment-10285\" class=\"wp-caption-text\">Copy Files From Remote Server To Local<\/figcaption><\/figure>\n<p>There are several more ways to use\u00a0<strong>rsync\u00a0<\/strong>command but these two are the most used and easiest commands to copy\/sync files and directories between\u00a0remote server to local.<\/p>\n<hr \/>\n<p>I hope now you can easily use the\u00a0<strong>rsync\u00a0<\/strong>command in Linux. Other than this, if this still didn\u2019t knock your mind then you can visit\u00a0<a href=\"http:\/\/b2bhostingclub.com\"><strong>b2bhostingclub.com <\/strong><\/a>and open a Free Support Ticket. Our experienced technical team will be happy to assist you. Other than this, you can purchase Reseller hosting or Dedicated hosting from B2bhostingclub and Save some extra amount as we\u2019re one of the <em>Cheapest Hosting Providers<\/em>\u00a0across the Internet.<\/p>\n<h4>Now Don\u2019t Say \u201cWho wants to Save Money?\u201d<\/h4>\n<h4>Everybody Wants!!<\/h4>\n","protected":false},"excerpt":{"rendered":"<p>What is Rsync Command In Linux? The Rsync command in Linux is mostly used to copy and synchronize files and directories remotely along with copying them locally in Linux\/Unix system. With the help of the\u00a0rsync\u00a0command, you can easily copy and synchronize your data remotely and locally across the directories, disks, and networks. You can also [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":1503,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1497","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-hosting"],"_links":{"self":[{"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/posts\/1497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/comments?post=1497"}],"version-history":[{"count":4,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/posts\/1497\/revisions"}],"predecessor-version":[{"id":1506,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/posts\/1497\/revisions\/1506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/media\/1503"}],"wp:attachment":[{"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/media?parent=1497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/categories?post=1497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/b2bhostingclub.com\/blog\/wp-json\/wp\/v2\/tags?post=1497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}