很多時(shí)候我們都要進(jìn)行一些大文件的傳輸,比如數(shù)據(jù)的備份,遷移等等。 下面介紹幾種簡(jiǎn)單的快速傳輸文件的方法,希望對(duì)大家有幫助。
環(huán)境:
host1:192.168.1.101
host2:192.168.1.104
1、使用scp
將host1中的file.tar.gz拷貝到host2的/tmp目錄
scp file.tar.gz root@192.168.1.104:/tmp
將host1中的/root目錄整個(gè)拷貝到host2的/tmp目錄下(參數(shù):-r 遞歸的復(fù)制整個(gè)文件夾)
scp -r /root root@192.168.1.104:/tmp或scp -r /root/ root@192.168.1.104:/tmp
拷貝文件夾內(nèi)容里的所有內(nèi)容
scp -r /root/* root@192.168.1.104:/tmp
2、使用rsync
通過(guò)ssh通道將host1上的目錄/etc備份到host2的/tmp目錄 在host2執(zhí)行以下指令:
rsync -av -e ssh file.tar.gz 192.168.1.101:/etc /tmp
加上- -progress可以觀察傳輸進(jìn)度
3、使用nc
將file.tar.gz從host2拷貝到host1:
host1:nc -l 444 >file.tar.gz #先啟用監(jiān)聽(tīng)host2:nc 192.168.1.101 444 《file.tar.gz
將目錄/etc從host2拷貝到host1:
host1:nc -l 123 |tar zxvf - #先啟用監(jiān)聽(tīng)host2:tar zcvf - . |nc 192.168.1.101 123
轉(zhuǎn)載自:http://www.cszhi.com/20120311/linux-translation-skill.html
聯(lián)系客服