rsync Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

Rsync (Remote Sync) is a powerful command-line tool in Linux that allows users to synchronize files and directories between local and remote systems or between two local directories. Rsync uses the delta-transfer algorithm and can transfer data over SSH, making it an efficient and secure choice for data synchronization.

Linux rsync Command Syntax

The syntax for the rsync command is as follows:

Where:

  • options: A combination of flags and settings that control the behavior of the rsync command.
  • source: The source file or directory to be synchronized.
  • destination: The destination file or directory where the synchronized data will be stored.

rsync Command Options:

  • -a, --archive: Archive mode; it is equivalent to -rlptgoD, which preserves symbolic links, permissions, timestamps, owner, group, and device files while recursively copying directories.
  • -v, --verbose: Provides more detailed information about the synchronization process.
  • -z, --compress: Compresses the data during transfer, reducing the amount of bandwidth used.
  • -e, --rsh=COMMAND: Specifies the remote shell to use for data transfer, such as using SSH with -e 'ssh'.
Sharpen Your Fundamentals with Free Learning

Example Usages

  • Synchronize a local directory with a remote directory:

    Output:

    Explanation: This command synchronizes the /local/dir/ directory with the /remote/dir/ directory on the remote host, using archive mode (-a), verbose output (-v), and compression (-z).

  • Synchronize a remote directory with a local directory:

    Output:

    Explanation: This command synchronizes the /remote/dir/ directory on the remote host with the /local/dir/ directory, using archive mode (-a), verbose output (-v), and compression (-z).

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Tips

  • Always include a trailing slash (/) at the end of the source directory to prevent rsync from creating an additional directory level at the destination.

  • Use the --dry-run option to simulate the synchronization process without making any actual changes.

Advanced Use Cases of rsync Command in Linux

  • Synchronize files while preserving hard links:

    Output:

    Explanation: This command synchronizes files and directories while preserving hard links (-H) in addition to using archive mode (-a), verbose output (-v), and compression (-z).

  • Synchronize files and exclude specific files or directories:

    Output:

    Explanation: This command synchronizes files and directories while excluding specific files or directories using the --exclude option, in addition to using archive mode (-a), verbose output (-v), and compression (-z).

  • Synchronize files with bandwidth limit:

    Output:

    Explanation: This command synchronizes files and directories with a bandwidth limit of 100 KB/s, using the --bwlimit option, in addition to using archive mode (-a), verbose output (-v), and compression (-z).

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • Rsync is a powerful and efficient tool for synchronizing files and directories.

  • It supports local and remote synchronization, as well as data compression and bandwidth limiting.

  • Rsync can transfer data securely using SSH and can preserve file attributes, such as permissions and timestamps.