linux、unix下传递文件(scp、ftp)

1、scp(linux到linux)

scp常用的一些参数:
-1    强制scp命令使用协议ssh1
-2    强制scp命令使用协议ssh2
-4    强制scp命令只使用IPv4寻址
-6    强制scp命令只使用IPv6寻址
-B    使用批处理模式(传输过程中不询问传输口令或短语)
-C    允许压缩。(将-C标志传递给ssh,从而打开压缩功能)
-p     保留原文件的修改时间,访问时间和访问权限。
-q    不显示传输进度条。
-r    递归复制整个目录。
-v     详细方式显示输出。


命令格式:
scp -r local_file remote_username@remote_ip:remote_file  --复制本地文件到远程
scp -r remote_username@remote_ip:remote_file local_file  --复制远程文件到本地


例子:

下载:复制远程10.10.10.10机器的文件夹shell到本地10.10.10.11机器的/mnt下面。

[root@linux2 mnt]# scp -r root@10.10.10.10:/u01/shell /mnt
The authenticity of host '10.10.10.10 (10.10.10.10)' can't be established.
RSA key fingerprint is c0:d5:ff:51:79:6c:10:e0:29:08:d3:dd:b6:09:14:51.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.10.10' (RSA) to the list of known hosts.
root@10.10.10.10's password: 
nohup.out                                                                                                                                                     100%  214KB 214.3KB/s   00:00    
t.sql                                                                                                                                                         100%  251     0.3KB/s   00:00    
tt1.sh                                                                                                                                                        100%  113     0.1KB/s   00:00    
tt2.sh                                                                                                                                                        100%  117     0.1KB/s   00:00    
test.sh                                                                                                                                                       100%  321     0.3KB/s   00:00    
test.sql                                                                                                                                                      100%   83     0.1KB/s   00:00    
tt3.sh                                                                                                                                                        100%   89     0.1KB/s   00:00    
tt4.sh                                                                                                                                                        100%   92     0.1KB/s   00:00    


上传:复制本地10.10.10.10机器的文件夹shell到远程10.10.10.11机器的/mnt下面。

[root@linux1 u01]# scp -r /u01/shell/ root@10.10.10.11:/mnt/
root@10.10.10.11's password: 
nohup.out                                                                                                                                                     100%  214KB 214.3KB/s   00:00    
t.sql                                                                                                                                                         100%  251     0.3KB/s   00:00    
tt1.sh                                                                                                                                                        100%  113     0.1KB/s   00:00    
tt2.sh                                                                                                                                                        100%  117     0.1KB/s   00:00    
test.sh                                                                                                                                                       100%  321     0.3KB/s   00:00    
test.sql                                                                                                                                                      100%   83     0.1KB/s   00:00    
tt3.sh                                                                                                                                                        100%   89     0.1KB/s   00:00    
tt4.sh                                                                                                                                                        100%   92     0.1KB/s   00:00    

2、ftp(linux到unix)

[root@localhost ~]# cd /u01/app/awr
[root@localhost awr]# ll
total 0
[root@localhost awr]# ftp 10.18.1.30
Connected to 10.18.1.30.
220 hnpsdba FTP server (Revision 4.0 Version wuftpd-2.6.1 Wed Jun 18 07:11:14 GMT 2008) ready.
534 Kerberos Authentication not enabled.
534 Kerberos Authentication not enabled.
KERBEROS_V4 rejected as an authentication type
Name (10.18.1.30:root): root
331 Password required for root.
Password:
230 User root logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /u01/app/awr
250 CWD command successful.
ftp> ls -l
227 Entering Passive Mode (10,18,1,30,94,118)
150 Opening ASCII mode data connection for /usr/bin/ls.
总数 5650
-rw-r--r--   1 oracle     oinstall    657592 8月22日 09:27 awrrpt_2_100_101.html
-rw-r--r--   1 oracle     oinstall    623500 8月22日 09:30 awrrpt_2_104_105.html
-rw-r--r--   1 oracle     oinstall   1002693 8月22日 09:26 awrrpt_2_90_91.html
-rw-r--r--   1 oracle     oinstall    607147 8月22日 09:29 awrrpt_2_94_95.html
226 Transfer complete.
ftp> get awrrpt_2_94_95.html
local: awrrpt_2_94_95.html remote: awrrpt_2_94_95.html
227 Entering Passive Mode (10,18,1,30,124,98)
150 Opening BINARY mode data connection for awrrpt_2_94_95.html (607147 bytes).
226 Transfer complete.
607147 bytes received in 0.028 seconds (2.1e+04 Kbytes/s)
ftp> quit
221-You have transferred 607147 bytes in 1 files.
221-Total traffic for this session was 608234 bytes in 2 transfers.
221-Thank you for using the FTP service on hnpsdba.
221 Goodbye.
[root@localhost awr]# pwd
/u01/app/awr
[root@localhost awr]# ll
total 600
-rw-r--r-- 1 root root 607147 Aug 23 16:38 awrrpt_2_94_95.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值