tar 压缩命令的最有用的一个选项了

tar cf - rootfs.rls | ssh root@192.168.1.2  "tar -C /home/et3320 -xvf -"


把整个的rootfs.rls目录给上传到1.2的/home/et3320目录。 且tar不改变任何连接和文件等的信息。

注意的一点是,打包和登陆的用户都必须是root用户,否则,某些文件或者设备会丢失。

Because tar saves the ownership and permissions of files in the archive and retains the full
directory structure, as well as symbolic and hard links, using tar is an excellent way to copy
or move an entire directory tree from one place to another on the same system (or even
between different systems, as we'll see).

And tar allows you to write an ahchive to standard output. If you specify a - as the tar file to read or write, the data will be read from or write to the standard input or standard output. 

We start in the directory rootfs and create a tar file of the current directory, which is written to standard output. This archive is read by a ssh  and then runs tar xvf, reading from standard input. No tar file is ever written to disk; the data is sent entirely via pipe from one tar process to another. The second tar process has the v option that prints each file as it's extracted; in this way, we can verify that the command is working as expected.
 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值