shellinfo tips

Discover Rsync

In the realm of file synchronization and data transfer, ‘rsync’ stands as a powerful and flexible tool. Originally released in 1996, rsync, which stands for “remote synchronization,” is a utility software and network protocol for Unix-like systems that synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate.

Understanding Rsync

Rsync is commonly used for backups and mirroring and as an improved copy command for everyday use. It offers many options that control every aspect of its behavior and permit very flexible specification of the set of files to be copied. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination.

Basic Usage of Rsync

The basic syntax of rsync is quite simple:

rsync options source destination

For example, to copy a file from one location to another, you would use:

rsync -zvh backup.tar /tmp/backups/

This command copies the file backup.tar to the directory /tmp/backups/. The options -zvh tell rsync to compress the data (-z), use human-readable sizes (-h), and display verbose output (-v).

Rsync for Remote Files

Rsync can also synchronize files with a remote server. For example:

rsync -avz file.txt username@remote:/path/to/directory/

This command copies file.txt to the /path/to/directory/ directory on the remote server. You would replace username with your username on the remote server and remote with the server’s address.

Rsync for Directory Synchronization

Rsync is also commonly used to synchronize directories:

rsync -avz /path/to/source/directory/ username@remote:/path/to/destination/directory/

This command synchronizes the source directory with the destination directory on the remote server, copying over any files that are different.

Rsync’s flexibility allows for a wide range of uses. Here are some additional examples:

Rsync with Delete Option: If you want rsync to delete files at the destination that no longer exist at the source, you can use the –delete option:

rsync -avz --delete /path/to/source/directory/ username@remote:/path/to/destination/directory/

This command will synchronize the directories and delete any files in the destination directory that are not present in the source directory.

Rsync with Include and Exclude: You can specify patterns to include or exclude files or directories:

rsync -avz --include 'R*' --exclude '*' /path/to/source/directory/ /path/to/destination/directory/

This command will only synchronize files in the source directory that start with ‘R’, excluding all other files.

Rsync with Progress Option: If you want to display the progress during transfer, you can use the –progress option:

rsync -avz --progress /path/to/source/directory/ username@remote:/path/to/destination/directory/

This command will display progress during the rsync execution, showing you how much data has been transferred over time.

Rsync with Compression: If you’re transferring large files or directories, you can use the -z or –compress option to reduce the data size:

rsync -avz --compress /path/to/source/directory/ username@remote:/path/to/destination/directory/

This command will compress the file data as it is sent to the destination machine, which can significantly speed up the transfer.

Rsync over a Specific SSH Port: If your SSH server listens on a different port, you can specify the port with the -e option:

rsync -avz -e 'ssh -p 2222' /path/to/source/directory/ username@remote:/path/to/destination/directory/

This command will connect to the SSH server on port 2222.


Rsync is a powerful tool for file and directory synchronization. Its flexibility and efficiency make it a favorite among system administrators and power users. With a little practice, it can easily become an essential part of your command-line toolkit.

shellinfo tips

DIG – dnsutils

In the world of networking, understanding how to retrieve information about domain names is crucial. One tool that makes this task easier is ‘dig’, a powerful command-line utility available on Unix-based systems like Linux and macOS.

‘Dig’ stands for ‘Domain Information Groper’. It is a flexible tool for interrogating DNS (Domain Name System) name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried.

How to Use the ‘dig’ Command

The basic syntax of the ‘dig’ command is straightforward:
dig [name] [type]

Here, ‘name’ is the name of the resource record that is to be looked up, and ‘type’ indicates the type of query. If no type argument is supplied, ‘dig’ will perform a lookup for an A record.

For example, to find the IP address associated with a domain, you would use:

This command will return a variety of information, including the ‘ANSWER SECTION’, which contains the A record for ‘‘ (i.e., its IP address).

Using ‘dig’ with Different Query Types

You can use ‘dig’ to query different types of records.

  1. MX (Mail Exchange) Records: These records are used in routing email. To query MX records, you would use:

dig MX

This command will return the MX records for ‘’, showing you the mail servers that are set up to receive email for that domain.

  1. NS (Name Server) Records: These records indicate which DNS servers are authoritative for a domain. To query NS records, use:

dig NS

This command will return the NS records for ‘’, showing you which name servers are responsible for information about the domain.

  1. TXT (Text) Records: These records are often used to hold machine-readable data, such as SPF data to combat email spoofing or DKIM data for email validation. To query TXT records, use:

dig TXT

This command will return the TXT records for ‘’, which could include various types of information depending on what the domain uses TXT records for.

  1. CNAME (Canonical Name) Records: These records are used to alias one name to another. To query CNAME records, use:


This command will return the CNAME record for ‘‘, if one exists, showing you what domain name ‘‘ is an alias for.

  1. SOA (Start of Authority) Records: These records provide authoritative information about a DNS zone, including the primary name server, the email of the domain administrator, the domain serial number, and several timers relating to refreshing the zone. To query SOA records, use:

dig SOA

This command will return the SOA record for ‘’, providing a wealth of information about how the domain is configured.


The ‘dig’ command is a versatile tool for anyone who needs to work with DNS. Whether you’re a system administrator troubleshooting network issues or a web developer setting up a new domain, ‘dig’ offers a quick and reliable way to query DNS records.