Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
Rsync Command In Linux With Examples [Updated]

Rsync Command In Linux With Examples [Updated]

Posted on February 11, 2022 By admin No Comments on Rsync Command In Linux With Examples [Updated]

Rsync command in Linux examples

rsync is an open-source utility that stands for remote sync. rsync is free to use file transfer tool and synchronization tool that provides fast incremental file transfer. The rsync daemon can now handle a client address with an implied “%scope” suffix. Rysnc is also used as an incremental backup tool in Linux.

What Is The Use Of Rsync?

Rsync is basically used to copy files locally or in between remote hosts. Rsync communicates with a remote host using a remote-shell program such as ssh or rsh or by using its own rsync daemon directly via TCP. Rsync can use any transparent remote shell, including ssh or rsh and it doesn’t require any super usage privileges too. Rsync does not support copying files between two remote hosts.

Along with the files, Rsync also copies links, devices, owners, groups, and permissions of the respective files.

Rsync Command In Linux With Examples [Updated]

Rsync comes pre-installed on most Linux distributions but you can also install the rsync package with the help of the following commands.

1. Install Rsync On Ubuntu/Debian/Mint

Command to install Rsync on Ubuntu, Debian & Mint.

sudo apt-get install rsync

2. Install Rsync On Arch Linux

Command to install Rsync on Arch Linux

pacman -S rsync

3. Install Rsync On Fedora/CentOS/RHEL/Rocky Linux/AlmaLinux

sudo dnf install rsync

4. Install Rsync On openSUSE

sudo zypper install rsync

5. Install Rsync On Gentoo

emerge sys-apps/rsync

Rsync Command To Copy/Sync Files And Directory Locally

Command to copy/sync files locally:

READ More Relevant Stuff:  How To Fix ‘Got permission denied while trying to connect to the Docker daemon socket’ Error In Ubuntu

Let’s have a look into the command for copying files and directories locally from one location to another location. using rsync command. In this example, we will take a file example.tar that needs to be copied to another folder. If the destination folder is not available then this command will create one for you.

rsync -zvh example.tar /home/itsubuntu/foldername

created directory /home/itsubuntu/foldername
example.tar

Command to copy/sync a directory on Local Computer:

The following command will transfer or sync the content of one directory to a different directory in the same machine.

rsync -avzh /root/blogfile_directory /tmp/backups/

Rsync To Copy/Sync Files And Directory To Or From A Remote Server

Command to copy a Directory from Local Server to a Remote Server:

The following command will sync a directory from a local machine to a remote machine.

rsync -avzh /root/blogfiledirectory [email protected]:/root/

Command to Copy/Sync a Remote Directory to a Local Machine

The following command will sync a remote directory to a local directory.

rsync -avzh [email protected] :/root/directoryfromremotemachine /localmachine/mydirectory

How to Transfer Files with Rsync over SSH

SSH  is the most popular and secure protocol for data transfer. You can transfer files and directories with rsync over SSH from and to remote servers. While using rsync, you need to specify a protocol with rsync with the “-e” option and the protocol name you want to use.

Command to Copy a File from a Remote Server to a Local Server with SSH

rsync -avzhe ssh [email protected]:/root/example.cfg /localmachine/mydirectory

Command to Copy a File from a Local Server to a Remote Server with SSH

rsync -avzhe ssh example.tar.gz [email protected]:/remoteserverdir/

How to Transfer Files with Rsync By Excluding file

You need to use two options include and exclude while transferring files if you want to include or exclude certain files by specifying parameters.

READ More Relevant Stuff:  3 Ways To Fix “No Space Left on Device” Error In Linux

The basic syntax for the rsync exclude option looks like this:

rsync [OPTIONS] --exclude 'file_or_directory' source/ destination/

Run the following command to exclude a file while copying the directory.

rsync -av --exclude 'testfilename.txt' sourcedir/ destinationdir/

If you want to exclude the specific directory, then run the following command:

rsync -av --exclude 'dirname' sourcedir/ destinationdir/

Exclude a Specific File Type using Rsync

If you want to exclude a certain file type while copying data then use the following command.

rsync -av --exclude '*.mp3' sourcedir/ destinationdir/

.mp3 files will be excluded from the list.

How To Ubuntu

Post navigation

Previous Post: Best Unetbootin Alternatives For Linux & Windows [2023]
Next Post: How To Recursively Change The File’s Permissions In Linux [CHMOD Linux]

Related Posts

Install PHP Mcrypt Extension On Ubuntu 22.04/Debian [Updated] Install PHP Mcrypt Extension On Ubuntu 22.04/Debian [Updated] How To Ubuntu
Fix "The following signatures couldn’t be verified": Ubuntu 22.04 GPG error Fix “The following signatures couldn’t be verified” : Ubuntu 22.04 GPG error How To Ubuntu
Basic Idea Of The Linux Filesystem Described Basic Idea Of The Linux Filesystem Described How To Ubuntu
How To Install Microsoft Office On Linux 2023 How To Install Microsoft Office On Linux 2023 How To Ubuntu
Best GNOME Shell Extensions For Ubuntu 20.04 LTS/ 22.04 LTS Best GNOME Shell Extensions For Ubuntu 20.04 LTS/ 22.04 LTS How To Ubuntu
How To Access Linux Files From Windows 11 How To Access Linux Files From Windows 11 [2023] How To Ubuntu

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023
  • Linux Wget Examples September 27, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
  • Search Jobs
  • Post a Job
  • Job Dashboard
  • Contact Us
  • About US
  • Cookie Policy
  • Terms and Conditions
  • Privacy Policy
  • Sitemap
  • Write For US

Tags

android apps centos ChatGPT command Commands Debian deepin Desktop docker Fedora fix game games Gaming gnome google kernel linux linux commands linux kernel Linux laptops Linux Mint Linux themes minecraft NVIDIA Python Raspberry Pi sysadmin themes ubuntu ubuntu 18.04 Ubuntu 18.04 LTS Ubuntu 20.04 ubuntu 20.04 lts Ubuntu 22.04 LTS Ubuntu games Ubuntu kernel ubuntu themes ubuntu tutorial VirtualBox Windows Windows 11 Wine WSL
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at [email protected]
  • Technical Writer – Flexible Location

    • Auburn, CA
    • PG&E Corporation
    • Full Time
  • Technical Writer

    • Orlando, FL
    • Careerbuilder-US
    • Full Time
  • Azure Developer

    • Des Moines, IA
    • Inabia Software & Consulting Inc.
    • Full Time
  • Service Writer / Advisor

    • Walla Walla, WA
    • Pape' Machinery, Inc
    • Full Time
  • Azure Lead

    • San Jose, CA
    • Sparktek
    • Full Time
  • Azure Developer

    • Chicago, IL
    • Expert Technology Services
    • Full Time
  • Senior Sales Data Scientist

    • Boston, MA (Remote)
    • Insight Global
    • Full Time
  • Senior AI Policy Engineer

    • Bethesda, MD
    • SAIC
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme