Linux系统中的文件传输——scp命令/rsync命令/文件归档及压缩

scp命令

***scp 本地文件 远程主机用户@远程主机ip:远程主机目录的绝对路径***
   scp  file1   root@172.25.254.20:/root/Desktop


***scp 远程主机用户@远程主机ip:远程主机文件的绝对路径  本地文件***
   scp root@172.25.254.20:/mnt/westos_rhel8 /root/Desktop

rsync命令

rsync -r       root@172.25.254.20:/root/Desktop    /mnt    ##同步目录本身及目录中的文件
rsync -r       root@172.25.254.20:/root/Desktop/   /mnt    ##只同步目录中的文件
rsync -rl      root@172.25.254.20:/root/Desktop/   /mnt    ##同步连接
rsync -rlp     root@172.25.254.20:/root/Desktop/   /mnt    ##同步权限
rsync -rlpog   root@172.25.254.20:/root/Desktop/   /mnt    ##同步用户组
rsync -rlpogt  root@172.25.254.20:/root/Desktop/   /mnt    ##同步时间
rsync -rD      root@172.25.254.20:/dev/pts         /mnt    ##同步设备文件

rsync和scp命令的对比

rsync命令在文件传输中所需要的时间远小于scp命令的时间。

原因:

实验如下:

 

文件归档及压缩

文件归档——tar命令

tar 
tar c             ##创建
tar f             ##指定文件名称
tar x             ##解档
tar v             ##显示过程
tar t             ##查看
tar r             ##向归档文件中添加文件
tar --get         ##解档指定文件
tar --delete      ##删除指定文件
tar -C            ##指定解档路径

文件压缩——zip/gzip/bzip/xz命令

***zip***
zip -r  mnt.tar.zip  mnt.tar      ##zip格式压缩
unzip   mnt.tar.zip               ##zip格式解压


***gzip***
gzip    mnt.tar                   ##gzip格式压缩
gunzip  mnt.tar.gz                ##gzip格式解压

***bzip***
bzip2    mnt.tar                  ##bzip2格式压缩
bunzip2  etc.tar.bz2              ##bzip2格式解压

***xz***
xz     mnt.tar                    ##xz格式压缩
unxz   mnt.tar.xz                 ##xz格式解压

tar+压缩——gz/bz/xz格式

***gzip***
tar  zcf   etc.tar.gz   /etc
tar  zxf   etc.tar.gz


***bzip2***
tar  jcf   etc.tar.ba2   /etc
tar  jxf   etc.tar.ba2

***xz***
tar  Jcf   etc.tar.xz    /etc
tar  Jxf   etc.tar.xz

ending......

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值