Ubuntu 服务器之间拷贝文件命令
2016-02-19 11:18
465 查看
从本服务器上访问另一个服务器 ssh zhangmeng@10.167.174.123 然后输入密码即可。
1.拷贝远程服务器的目录到本地服务器
远程服务器192.168.1.112上面/tmp目录下面有个test目录,里面有个文件名为test,内容也为test
root@ubuntu:/tmp# cat test/test
test
拷贝远程服务器192.168.1.112的目录/tmp/test到当前目录下。
[root@CentOS_Test_Server tmp]# scp
-r root@192.168.1.112:/tmp/test ./
The authenticity of host '192.168.1.112 (192.168.1.112)' can't be established.
RSA key fingerprint is 64:76:a6:1e:23:76:ec:25:5e:c2:f3:ef:fc:ad:48:7b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.112' (RSA) to the list of known hosts.
root@192.168.1.112's password:
test 100% 5 0.0KB/s 00:00
注意拷贝到本地服务器后形成的目录结构为/tmp/test,而不是/tmp/tmp/test,一定要注意,这里比较容易混淆,经过自己亲自测试,再碰到类似的问题心里就有底了。
[root@CentOS_Test_Server tmp]# ls test/
test
2.拷贝远程服务器的文件到本地服务器
将1中拷贝过来的目录test删除
rm -rf test
[root@CentOS_Test_Server tmp]# ls -l | grep test | grep -v "grep"
拷贝远程服务器192.168.1.112的文件/tmp/test/test到当前目录下。
[root@CentOS_Test_Server tmp]# scp
root@192.168.1.112:/tmp/test/test ./
root@192.168.1.112's password:
test 100% 5 0.0KB/s 00:00
[root@CentOS_Test_Server tmp]# ls -l | grep test | grep -v "grep"
-rw-r--r-- 1 root root 5
Sep 22 14:07 test
3.拷贝本地服务器的目录到远程服务器
在/tmp目录下面建立目录dir111,在此目录下创建文件file111,内容为file111
[root@CentOS_Test_Server tmp]# mkdir dir111
[root@CentOS_Test_Server tmp]# echo 'content111' > dir111/file111
[root@CentOS_Test_Server tmp]# cat dir111/file111
content111
拷贝本地服务器的目录dir111到远程服务器的目录/tmp下
与上述1中类似,拷贝到远程服务器后形成的目录结构为/tmp/dir111,而不是/tmp/tmp/dir111,一定要注意,这里比较容易混淆。
不管拷贝命令是scp -r dir111 root@192.168.1.112:/tmp还是scp -r /tmp/dir111 root@192.168.1.112:/tmp,在远程服务器上面生成的目录结构均一样,我亲自测试过了。
[root@CentOS_Test_Server tmp]# scp -r /tmp/dir111 root@192.168.1.112:/tmp
root@192.168.1.112's password:
file111 100% 11 0.0KB/s 00:00
远程服务器192.168.1.112上面的内容
root@ubuntu:/tmp# ls
dir111 test vmware-root
root@ubuntu:/tmp# cat dir111/file111
content111
4.拷贝本地服务器的文件到远程服务器
[root@CentOS_Test_Server tmp]# scp
dir111/file111 root@192.168.1.112:/tmp
root@192.168.1.112's password:
file111 100% 11 0.0KB/s 00:00
远程服务器192.168.1.112上面的内容
root@ubuntu:/tmp# ls
dir111 file111 test vmware-root
1.拷贝远程服务器的目录到本地服务器
远程服务器192.168.1.112上面/tmp目录下面有个test目录,里面有个文件名为test,内容也为test
root@ubuntu:/tmp# cat test/test
test
拷贝远程服务器192.168.1.112的目录/tmp/test到当前目录下。
[root@CentOS_Test_Server tmp]# scp
-r root@192.168.1.112:/tmp/test ./
The authenticity of host '192.168.1.112 (192.168.1.112)' can't be established.
RSA key fingerprint is 64:76:a6:1e:23:76:ec:25:5e:c2:f3:ef:fc:ad:48:7b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.112' (RSA) to the list of known hosts.
root@192.168.1.112's password:
test 100% 5 0.0KB/s 00:00
注意拷贝到本地服务器后形成的目录结构为/tmp/test,而不是/tmp/tmp/test,一定要注意,这里比较容易混淆,经过自己亲自测试,再碰到类似的问题心里就有底了。
[root@CentOS_Test_Server tmp]# ls test/
test
2.拷贝远程服务器的文件到本地服务器
将1中拷贝过来的目录test删除
rm -rf test
[root@CentOS_Test_Server tmp]# ls -l | grep test | grep -v "grep"
拷贝远程服务器192.168.1.112的文件/tmp/test/test到当前目录下。
[root@CentOS_Test_Server tmp]# scp
root@192.168.1.112:/tmp/test/test ./
root@192.168.1.112's password:
test 100% 5 0.0KB/s 00:00
[root@CentOS_Test_Server tmp]# ls -l | grep test | grep -v "grep"
-rw-r--r-- 1 root root 5
Sep 22 14:07 test
3.拷贝本地服务器的目录到远程服务器
在/tmp目录下面建立目录dir111,在此目录下创建文件file111,内容为file111
[root@CentOS_Test_Server tmp]# mkdir dir111
[root@CentOS_Test_Server tmp]# echo 'content111' > dir111/file111
[root@CentOS_Test_Server tmp]# cat dir111/file111
content111
拷贝本地服务器的目录dir111到远程服务器的目录/tmp下
与上述1中类似,拷贝到远程服务器后形成的目录结构为/tmp/dir111,而不是/tmp/tmp/dir111,一定要注意,这里比较容易混淆。
不管拷贝命令是scp -r dir111 root@192.168.1.112:/tmp还是scp -r /tmp/dir111 root@192.168.1.112:/tmp,在远程服务器上面生成的目录结构均一样,我亲自测试过了。
[root@CentOS_Test_Server tmp]# scp -r /tmp/dir111 root@192.168.1.112:/tmp
root@192.168.1.112's password:
file111 100% 11 0.0KB/s 00:00
远程服务器192.168.1.112上面的内容
root@ubuntu:/tmp# ls
dir111 test vmware-root
root@ubuntu:/tmp# cat dir111/file111
content111
4.拷贝本地服务器的文件到远程服务器
[root@CentOS_Test_Server tmp]# scp
dir111/file111 root@192.168.1.112:/tmp
root@192.168.1.112's password:
file111 100% 11 0.0KB/s 00:00
远程服务器192.168.1.112上面的内容
root@ubuntu:/tmp# ls
dir111 file111 test vmware-root
相关文章推荐
- java反射详解
- iTween基础之Rotate(旋转角度)
- cocos ide 调试lua 程序自动关闭问题的解决
- iTween基础之Rotate(旋转角度)
- apach hadoop2.6 集群利用Phoenix 4.6-hbase 批量导入并自动创建索引
- csharp:正则表达式采集网页数据
- tomcat项目部署到weblogic11
- Linux 网络配置
- SQLAlchemy指南(tutorial)
- JMeter使用技巧
- 作为DBA,如果数据不小心删除掉了,怎么恢复啊?比如drop掉了表,或者truncate删除掉了数据
- tomcat虚拟路径配置
- Java 中正确使用 hashCode 和 equals 方法
- Android学习路线(二十)运用Fragment构建动态UI
- (whh仅供自己参考)进行ip网络请求的步骤
- Git -- 从远程库克隆
- Ubuntu环境下的iptables的端口转发配置实例
- split分割文件命令
- ios开发常遇错误总结之Xcode路径问题
- java endsWith()和startsWith方法的解释