系统中的文件传输优化

1 scp

scp 本地文件  远程主机用户@远程主机ip:远程主机目录
scp 远程主机用户@远程主机ip:远程主机目录  本地文件

1.1 把本地文件复制到远程主机

在这里插入图片描述
若不想显示进度条可加-q

[root@westos Desktop]# scp -q  hh [email protected]:/mnt
root@192.168.0.11's password: 

传输目录加-r
在这里插入图片描述

1.2 把远程文件复制到本地

在这里插入图片描述

2 rsync

实验素材:
在这里插入图片描述
为了看到真实的传输时间,两台主机可建立免密登录:ssh-keygen。
实验:检测rsync的传输时间

在这里插入图片描述
Caq可加可不加。
得出scp三次执行时间几乎一样。而rsync第一次比以后的慢。它会自动检测是否存在,若存在则不重复操作。但好多东西没有上传完整。

3 rsync用法

rsync 文件 远程用户@远程主机ip:远程主机目录
rsync 远程用户@远程主机ip:远程主机目录 文件路径

-r 复制目录
-l 复制链接
-p 复制权限
-t 复制时间戳
-o 复制拥有者
-g 复制拥有组
–D 复制设备文件

-r 复制目录
在这里插入图片描述
/mnt 复制目录和内容;/mnt/ 只复制内容,不复制目录。

在这里插入图片描述
在这里插入图片描述

[root@westos mnt]# rsync -lr /mnt [email protected]:/mnt

[root@westos mnt]# rsync -lrp /mnt [email protected]:/mnt
[root@westos mnt]# rsync -lrpo /mnt [email protected]:/mnt
[root@westos mnt]# rsync -lrpog /mnt [email protected]:/mnt
[root@westos mnt]# rsync -lrpogt /mnt [email protected]:/mnt

同步字符设备:
在这里插入图片描述

4 文件归档

在这里插入图片描述
在这里插入图片描述
添加:
在这里插入图片描述
解档删除
在这里插入图片描述
解档到指定位置-C

[root@westos Desktop]# tar xf mnt.tar -C /mnt

5 压缩、解压

5.1 zip

在这里插入图片描述

5.2 gzip

[root@westos Desktop]# gzip mnt.tar
[root@westos Desktop]# gunzip mnt.tar

5.3 bzip2

[root@westos Desktop]# bzip2 mnt.tar
[root@westos Desktop]# bunzip2 mnt.tar.bz2

5.4 xz

[root@westos Desktop]# xz mnt.tar
[root@westos Desktop]# unxz mnt.tar.xz

6 打包压缩一起完成

在这里插入图片描述

7 解包压缩一起完成

在这里插入图片描述

发布了63 篇原创文章 · 获赞 0 · 访问量 1167

猜你喜欢

转载自blog.csdn.net/weixin_2158/article/details/105324237