Rsync Linux Commands: ################################################################## Join our telegram channel for more : https://t.me/LinuxClassesEFXTv ################################################################## Q. What is RSYNC and how to use it to Synchronize files in Linux servers? - rsync is a powerful and versatile Linux command for transferring and synchronizing files between local and remote servers. This approach reduces bandwidth usage and speeds up transfers. Objective: To Synchronize file files on the Remote server in such a way that we are not required to copy them one by one. Easy access and less effort to copy and paste remotely. # Dependencies are -ssh -Local and remote machines should have rsync installed # Sonfigure ssh SH ssh key no password $ ssh-keygen (hit enter to set no password) $ ssh-copy-id -i ~/.ssh/id_rsa.pub userForKali@IPaddressForKali # Create a config folder in .ssh $ touch ~/.ssh/config $ chmod u=--- ~/.ssh/config $ chmod u=rw- ~/.ssh/config # Paste these in the config file host nameanything hostname 192.168.1.40 port 22 user devil IdentityFile ~/.ssh/id_rsa # Edit file /etc/ssh/sshd_config and add two lines at the end of the file PubkeyAuthentication yes PasswordAuthentication no # Basic Syntax of rsync rsync [OPTIONS] SOURCE DESTINATION # List the files in the local machine using rsync $ rsync files_directory_name # List the files in a remote machine $ rsync devil@192.168.1.40:~/devil/files # Sync a directory to another directory or location in a local machine only -a: Archive mode -v: Verbose mode -h: Human-readable output rsync -avh localfolder localfolder2 # Copy files (demo mode, it will check for errors) $ rsync --dry-run files devil@192.168.1.40:~/home # Copy files (demo mode, it will check for errors) -r recursively -v verbose $ rsync -rv --dry-run files devil@192.168.1.40:~/devil # copy without dry-run $ rsync -rv files devil@192.168.1.40:~/devil # Delete everything from your computer rm files/* # Copy from a remote server to the local system $ rsync -rv devil@192.168.1.40:~/devil/files/ files/ # Rename the file into local machine and sync again, it will keep both of the files by default $ rsync -rv --dry-run files devil@192.168.1.40:~/devil # Delete all the old files from the remote server and copy new files $ rsync -rv --delete files devil@192.168.1.40:~/devil # Check the files ls -l time has been modified on a remote server # Time sync keep same time using -a - archive mode $ rsync -rva --delete files devil@192.168.1.40:~/devil # Copy the files from the local to the remote server but # Delete the files from the local machine once its sent $ rsync -rva --remove-source-files files devil@192.168.1.40:~/devil [ BONUS COMMANDS ] How to connect to termux shell using SSH # Install ssh $ pkg install openssh # Change password $ passwd # Start ssh in termux $ sshd # copy the username whomi # Come to kali shell or ubuntu $ ssh -p 8022 u0_a245@10.5.1.19