Linux
System
Shell
Show current shell.
1 | echo $SHELL |
Show available shells.
1 | cat /etc/shells |
Change shell for current user.
1 | chsh |
Data
Synchronizing
Lsyncd
1 | brew install lsyncd |
Rsync
Rsync (Remote Sync): 10 Practical Examples of Rsync Command in Linux
rsync 用法教程
How To Use Rsync to Sync Local and Remote Directories
Linux下文件实时自动同步备份
Rsync (Remote Sync) is a most commonly used command for copying and synchronizing files and directories remotely as well as locally in Linux/Unix systems. With the help of rsync
command you can copy and synchronize your data remotely and locally across directories, across disks and networks, perform data backups and mirroring between two Linux machines.
Some advantages and features of Rsync command
- It efficiently copies and sync files to or from a remote system.
- Supports copying links, devices, owners, groups and permissions.
- It’s faster than
scp
(Secure Copy) becausersync
uses remote-update protocol which allows to transfer just the differences between two sets of files. First time, it copies the whole content of a file or a directory from source to destination but from next time, it copies only the changed blocks and bytes to the destination. - Rsync consumes less bandwidth as it uses compression and decompression method while sending and receiving data both ends.
Basic syntax of rsync command
1 | rsync [options] [source] [destination] |
Some common options used with rsync commands
- v: verbose
- r: copies data recursively (but don’t preserve timestamps and permission while transferring data
- a: archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
- z: compress file data
- h: human-readable, output numbers in a human-readable format
Examples
This following command will sync a single file on a local machine from one location to another location. Here in this example, a file name backup.tar needs to be copied or synced to /tmp/backups/ folder.
1 | rsync -zvh backup.tar /tmp/backups/ |