scp
-
scp 本地文件 远程主机用户@远程主机ip:远程主机目录的绝对路径
scp -r westosdir root@1.1.1.2:/root/Desktop
-
r表示复制目录
-
q 表示不显示进度
-
scp 远程主机用户@远程主机ip:远程主机文件的绝对路径 本地文件
rsync
rsync
- -r ##复制目录
- -l ##复制链接
- -p ##复制权限
- -t ##复制时间戳
- -o ##复制拥有者
- -g ##复制拥有组
- -D ##复制设备文件
建立素材
rsync -r /mnt root@1.1.1.2:/root/Desktop ##同步目录本身其目录中的文件
目标主机:
rsync -rl /mnt root@172.25.254.20:/root/Desktop/ /mnt ##同步链接
目标主机:
rsync -rlp /mnt root@172.25.254.20:/root/Desktop/ 同步权限
rsync -rlpog /mnt root@172.25.254.20:/root/Desktop/ 同步用户组
rsync -rlpogt /mnt root@172.25.254.20:/root/Desktop/ 同步时间
rsync -rD /mnt root@172.25.254.20:/dev/pts 同步设备文件
tar 归档
- 打包
tar cf etc.tar /etc
将目录etc连同内容打包,传输速度更快
- 查看包中的内容
tar tf etc.tar
- 解档(默认当前包的目录)
tar xf etc.tar
到指定目录/mnt
tar xf etc.tar -C /mnt
- 将文件放入已归档的包中
tar rf etc.tar file
- 接档指定一个文件
tar f etc.tar --get file
只解档file
- 删除包中一个文件
tar f etc.tar --delete file
文件的压缩
- zip
zip -r mnt.tar.zip mnt.tar zip格式压缩
unzip mnt.tar.zip zip格式解压缩
- gzip
gzip mnt.tar gzip格式压缩
gunzip mnt.tar.gz gzip格式解压缩
- bzip2 mnt.tar bzip2格式压缩
bunzip2 etc.tar.bz2 bzip2格式解压缩
- xz mnt.tar xz格式压缩
unxz mnt.tar.xz xz格式解压缩
tar+压缩(不支持zip格式)
-
gzip
tar zcf etc.tar.gz /etc
tar zxf etc.tar.gz
-
bzip2
tar jcf etc.tar.bz2 /etc
tar jxf etc.tar.bz2
-
xz
tar Jcf etc.tar.xz /etc
tar Jxf etc.tar.xz