Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 [email protected]:~/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 [email protected]:~/home
- # Copy files (demo mode, it will check for errors)
- -r recursively
- -v verbose
- $ rsync -rv --dry-run files [email protected]:~/devil
- # copy without dry-run
- $ rsync -rv files [email protected]:~/devil
- # Delete everything from your computer
- rm files/*
- # Copy from a remote server to the local system
- $ rsync -rv [email protected]:~/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 [email protected]:~/devil
- # Delete all the old files from the remote server and copy new files
- $ rsync -rv --delete files [email protected]:~/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 [email protected]:~/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 [email protected]:~/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 [email protected]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement