Linxu之间互相传送文件:
scp命令:
scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system时,用scp可以帮你把文件移出来。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然 rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。
从linux本机文件上传到另一台linux:(上传文件不是目录)
格式:
scp 要传的文件 root@目标ip:路径
scp –r 要传的目录 root@目标ip:路径
例子:
[root@localhost ~]# scp mysql-all.sql root@192.168.20.17:/root (传目录加-r选项)
The authenticity of host ‘192.168.20.17(192.168.20.17)‘ can‘t be established.
RSA key fingerprint isaf:35:80:f2:c3:83:47:52:9b:aa:51:48:aa:b8:eb:f8.
Are you sure you want to continueconnecting (yes/no)? y
Please type ‘yes‘ or ‘no‘: yes
Warning: Permanently added ‘192.168.20.17‘(RSA) to the list of known hosts.
root@192.168.20.17‘s password:
mysql-all.sql 100% 484KB 483.5KB/s 00:00
[root@localhost ~]#
Scp mysql-all.sql root@192.168.20.17:/root
scp命令 文件名 用户名@目标IP地址 路径
从linux下载文件到linux本机:
[root@localhost ~]# scp root@192.168.20.24:/root/mysql-auth.sql/root (传目录加-r选项)
The authenticity of host ‘192.168.20.24(192.168.20.24)‘ can‘t be established.
RSA key fingerprint iscc:41:f8:5f:05:13:8f:e5:ee:0f:30:5e:a7:34:ab:1d.
Are you sure you want to continueconnecting (yes/no)? yes
Warning: Permanently added ‘192.168.20.24‘(RSA) to the list of known hosts.
root@192.168.20.24‘s password:
mysql-auth.sql 100% 1909 1.9KB/s 00:00
[root@localhost ~]#
[root@en ~]# scp -r root@192.168.20.19:/root/20.24 /root
scp root@192.168.20.24:/root/mysql-auth.sql /root
scp命令 用户名@目标IP地址:文件路径 本地位置
原文地址:http://153744.blog.51cto.com/143744/1670475