As a Linux user, you are already familiar with basic commands like
rm. But have you ever heard of rsync? It's one of the most powerful and versatile commands in Linux, and it can save you a lot of time and effort when working with large files and directories. In this post, we'll dive deep into the world of
rsync and show you how to yse it to its full potential.
Before we get started, let's talk about what
rsync actually is.
Rsync stands for "remote synchronization", and it's a command-line utility that allows you to copy files and directories between different locations, either on the same computer or over a network.
rsync so powerful is its ability to transfer only the parts of files that have changed, rather than copying the entire file every time. This means that
rsync can save you a lot of time and bandwidth when transferring large files, especially over slow or unreliable connections.
The basic syntax for using
rsync is simple:
rsync source destination
For example, if you want to copy all the files in the directory
/mnt/backup, you would use the following command:
rsync /home/user/Documents /mnt/backup
rsync will copy all files and subdirectories from the source directory to the destination directory.
While the basic usage of
rsync is straightforward, there are many advanced options that can help you fine-tune the way
rsync works. Here are some of the most useful options:
--recursive: This option tells
rsyncto opy all files and subdirectories recursively, including any empty directories.
--delete: This option tells
rsyncto delete any files in the destination directory that are not present in the source directory. This is useful for keeping two directories in sync.
--progress: This options shows the progress of the file transfer in real-time, which can be useful when transferring large files.
--exclude: This option allows you to exclude certain files or directories from the transfer. For example, if you want to exclude all files with the extention
.log, you would use the following command:
rsync --exclude '*.log' source destination
Here are some additional tips and tricks to help you get the most out of
- Always use the
-voption for verbose output. This will help you see exactly what
rsyncis doing during the transfer.
- Use the
-hoption to display file sizes in a human-readable format (e.g., "10MB" instead of "10485760")
- If you are transferring a large number of files, consider using the
--partialoption, which allows
rsyncto resume interrupted transfers.
- If you are transferring files over a network, use the
-zoption to enable compression, which can save you bandwidth.
Rsync is a powerful and versatile command that can help you save time and effort when working with large files and directories. Whether you are transferring files over a network or backing up your data to an external drive,
rsync has the tools you need to get the job done. With the tips and tricks we've covered in this post, you'll be able to use
rsync to its full potential and become a master of this powerful Linux command.
Thank you for reading 🧑💻
Stay tuned for more 🚀
✌️ and logout