中文字幕精品亚洲无线码二区,国产黄a三级三级三级看三级,亚洲七七久久桃花影院,丰满少妇被猛烈进入,国产小视频在线观看网站

每天一個linux命令(60):scp命令

scp是secure copy的簡(jian)寫,用于在Linux下(xia)進行(xing)遠(yuan)程(cheng)拷(kao)貝文件的命令,和它類似的命令有(you)cp,不(bu)過cp只是在本(ben)機進行(xing)拷(kao)貝不(bu)能跨(kua)服務器(qi),而且scp傳輸(shu)是加密的。可能會稍微影響(xiang)(xiang)一下(xia)速(su)度。當你服務器(qi)硬盤變為只讀(du) read only system時,用scp可以幫(bang)你把文件移出來。另外,scp還(huan)非常不(bu)占資源,不(bu)會提高(gao)多少(shao)系統負荷,在這一點上,rsync就遠(yuan)遠(yuan)不(bu)及(ji)它了。雖然 rsync比scp會快(kuai)一點,但當小文件眾多的情況下(xia),rsync會導致硬盤I/O非常高(gao),而scp基本(ben)不(bu)影響(xiang)(xiang)系統正常使(shi)用。

1.命令格式:

scp [參數] [原路徑] [目(mu)標路徑]

2.命(ming)令功能:

scp是 secure copy的(de)縮(suo)寫(xie), ;scp是linux系統下基于ssh登陸進(jin)行安全的(de)遠程文(wen)件拷貝命令(ling)。linux的(de)scp命令(ling)可以(yi)在(zai)linux服務器之間復(fu)制文(wen)件和目(mu)錄(lu)

3.命令(ling)參數:

-1  強制scp命(ming)令使用協議(yi)ssh1  

-2  強制scp命(ming)令使用協議ssh2  

-4 ; 強制(zhi)scp命(ming)令(ling)只使用IPv4尋(xun)址  

-6  強制scp命令只使用IPv6尋址  

-B  ;使用批(pi)處理(li)模式(傳輸過(guo)程(cheng)中不詢問傳輸口令或(huo)短語(yu))  

-C  允許壓(ya)縮(suo)。(將-C標志傳遞給ssh,從(cong)而(er)打(da)開壓(ya)縮(suo)功能)  

-p 保留原文件的修改(gai)時間(jian),訪問時間(jian)和訪問權限。  

-q  不顯示傳輸進(jin)度條。  

-r  遞歸(gui)復(fu)制整(zheng)個目錄。  

-v 詳細方式顯(xian)示輸出。scp和(he)ssh(1)會顯(xian)示出整個過程的(de)調試信息。這些信息用于調試連接,驗證和(he)配置(zhi)問題。   

-c cipher  以cipher將數據傳(chuan)輸進行加密(mi),這個選(xuan)項將直接傳(chuan)遞給ssh。   

-F ssh_config  指定一個替代的ssh配置文(wen)件,此(ci)參數直接傳遞(di)給(gei)ssh。  

-i ;identity_file  從指定(ding)文件中讀取傳輸(shu)時使用(yong)的密鑰文件,此(ci)參數直接傳遞給ssh。    

-l limit ; 限定用戶所能使用的帶寬,以Kbit/s為單位。     

-o ssh_option  如果習慣(guan)于使用ssh_config(5)中的參數傳(chuan)遞方式,   

-P port  注意(yi)是大寫(xie)的P, port是指(zhi)定(ding)數據傳輸用到的端口(kou)號   

-S program  指定加(jia)密傳輸時所(suo)使用的程序。此(ci)程序必(bi)須能夠理解(jie)ssh(1)的選項(xiang)。

4.使用(yong)實例:

scp命令的實際應(ying)用概述(shu):  

從本地服(fu)務(wu)器復制(zhi)到遠(yuan)程服(fu)務(wu)器 

(1) 復(fu)制文件:  

命令(ling)格(ge)式(shi):  

scp local_file remote_username@remote_ip:remote_folder  

或者  

scp local_file remote_username@remote_ip:remote_file  

或(huo)者  

scp local_file remote_ip:remote_folder  

或者  

scp local_file remote_ip:remote_file  

第1,2個(ge)(ge)指(zhi)定了用(yong)戶名(ming)(ming),命令執行后需要輸入用(yong)戶密碼,第1個(ge)(ge)僅指(zhi)定了遠程(cheng)的目錄(lu),文(wen)件名(ming)(ming)字不變(bian),第2個(ge)(ge)指(zhi)定了文(wen)件名(ming)(ming)  

第3,4個沒有(you)指(zhi)定用戶(hu)名(ming),命(ming)令執行(xing)后需(xu)要輸入用戶(hu)名(ming)和密碼,第3個僅指(zhi)定了遠程的(de)目錄,文(wen)(wen)件名(ming)字不變,第4個指(zhi)定了文(wen)(wen)件名(ming)   

(2) 復制(zhi)目錄:  

命令格式:  

scp -r local_folder remote_username@remote_ip:remote_folder  

或(huo)者  

scp -r local_folder remote_ip:remote_folder  

第1個指定了用戶(hu)(hu)名,命(ming)令執(zhi)行(xing)后需要輸入用戶(hu)(hu)密碼(ma);  

第2個沒有指定用戶名,命令執(zhi)行后需要輸入(ru)用戶名和(he)密碼(ma);

  

從遠程服務器復制到(dao)本地服務器 

從遠(yuan)程復制到本地(di)的(de)scp命(ming)令與(yu)上面的(de)命(ming)令雷同(tong),只要將從本地(di)復制到遠(yuan)程的(de)命(ming)令后面2個參數互換順序就行了。

實例1:從遠處(chu)復制文件到(dao)本(ben)地目錄

命令(ling):

scp root@192.168.120.204:/opt/soft/nginx-0.5.38.tar.gz /opt/soft/

輸出(chu):

[root@localhost ~]# cd /opt/soft/
[root@localhost soft]# ll
總計 80072
drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5
drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5
drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16
drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak
-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin
drwxrwxrwx  2 root root     4096 09-21 01:16 mysql
drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file
drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32
drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0
[root@localhost soft]# scp root@192.168.120.204:/opt/soft/nginx-0.5.38.tar.gz /opt/soft/
root@192.168.120.204's password: 
nginx-0.5.38.tar.gz                                                                               100%  479KB 478.7KB/s   00:00    
[root@localhost soft]# ll
總計 80556
drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5
drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5
drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16
drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak
-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin
drwxrwxrwx  2 root root     4096 09-21 01:16 mysql
-rw-r--r--  1 root root   490220 03-15 09:11 nginx-0.5.38.tar.gz
drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file
drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32
drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0
[root@localhost soft]# 

說明:

從192.168.120.204機器上的(de)/opt/soft/的(de)目錄中下載(zai)nginx-0.5.38.tar.gz 文件到本地/opt/soft/目錄(lu)中

實例(li)2:從遠(yuan)處復制到本地

命令:

scp -r root@192.168.120.204:/opt/soft/mongodb /opt/soft/

輸(shu)出(chu):

[root@localhost soft]# ll
總計 80556
drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5
drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5
drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16
drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak
-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin
drwxrwxrwx  2 root root     4096 09-21 01:16 mysql
-rw-r--r--  1 root root   490220 03-15 09:11 nginx-0.5.38.tar.gz
drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file
drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32
drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0
[root@localhost soft]# scp -r root@192.168.120.204:/opt/soft/mongodb /opt/soft/
root@192.168.120.204's password: 
mongodb-linux-i686-static-1.8.5.tgz                                                               100%   28MB  28.3MB/s   00:01    
README                                                                                            100%  731     0.7KB/s   00:00    
THIRD-PARTY-NOTICES                                                                               100% 7866     7.7KB/s   00:00    
mongorestore                                                                                      100% 7753KB   7.6MB/s   00:00    
mongod                                                                                            100% 7760KB   7.6MB/s   00:01    
mongoexport                                                                                       100% 7744KB   7.6MB/s   00:00    
bsondump                                                                                          100% 7737KB   7.6MB/s   00:00    
mongofiles                                                                                        100% 7748KB   7.6MB/s   00:01    
mongostat                                                                                         100% 7808KB   7.6MB/s   00:00    
mongos                                                                                            100% 5262KB   5.1MB/s   00:01    
mongo                                                                                             100% 3707KB   3.6MB/s   00:00    
mongoimport                                                                                       100% 7754KB   7.6MB/s   00:00    
mongodump                                                                                         100% 7773KB   7.6MB/s   00:00    
GNU-AGPL-3.0                                                                                      100%   34KB  33.7KB/s   00:00    
[root@localhost soft]# ll
總計 80560
drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5
drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5
drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16
drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak
-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin
drwxr-xr-x  3 root root     4096 03-15 09:18 mongodb
drwxrwxrwx  2 root root     4096 09-21 01:16 mysql
-rw-r--r--  1 root root   490220 03-15 09:11 nginx-0.5.38.tar.gz
drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file
drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32
drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0
[root@localhost soft]# 

說明:

192.168.120.204機器上的(de)/opt/soft/中下載(zai)mongodb 目錄到(dao)本(ben)地的/opt/soft/目錄(lu)來。

實(shi)例3:上傳本地文件到(dao)遠(yuan)程機(ji)器指定目錄

命(ming)令:

scp /opt/soft/nginx-0.5.38.tar.gz root@192.168.120.204:/opt/soft/scptest

輸(shu)出:

上傳前目標機器的目標目錄:
[root@localhost soft]# cd scptest/
[root@localhost scptest]# ll
總計 0
[root@localhost scptest]# ll

本地機器上傳:
[root@localhost soft]# scp /opt/soft/nginx-0.5.38.tar.gz root@192.168.120.204:/opt/soft/scptest
root@192.168.120.204's password: 
nginx-0.5.38.tar.gz                                                                               100%  479KB 478.7KB/s   00:00    
[root@localhost soft]# 

上傳后目標機器的目標目錄:
[root@localhost scptest]# ll
總計 484
-rw-r--r-- 1 root root 490220 03-15 09:25 nginx-0.5.38.tar.gz
[root@localhost scptest]#

說明:

復制本地opt/soft/目(mu)錄下的文件nginx-0.5.38.tar.gz 到遠程機(ji)器192.168.120.204opt/soft/scptest目(mu)錄

實(shi)例4:上傳本地(di)目錄到(dao)遠程機器(qi)指定目錄

命(ming)令:

scp -r /opt/soft/mongodb root@192.168.120.204:/opt/soft/scptest

輸出:

上傳前目標機器的目標目錄:
[root@localhost ~]# cd /opt/soft/scptest/
[root@localhost scptest]# ll
總計 484
-rw-r--r-- 1 root root 490220 03-15 09:25 nginx-0.5.38.tar.gz
[root@localhost scptest]# 
本地機器上傳:
[root@localhost ~]# scp -r /opt/soft/mongodb root@192.168.120.204:/opt/soft/scptest
root@192.168.120.204's password: 
mongodb-linux-i686-static-1.8.5.tgz                                                               100%   28MB  28.3MB/s   00:01    
README                                                                                            100%  731     0.7KB/s   00:00    
THIRD-PARTY-NOTICES                                                                               100% 7866     7.7KB/s   00:00    
mongorestore                                                                                      100% 7753KB   7.6MB/s   00:00    
mongod                                                                                            100% 7760KB   7.6MB/s   00:01    
mongoexport                                                                                       100% 7744KB   7.6MB/s   00:00    
bsondump                                                                                          100% 7737KB   7.6MB/s   00:00    
mongofiles                                                                                        100% 7748KB   7.6MB/s   00:00    
mongostat                                                                                         100% 7808KB   7.6MB/s   00:01    
mongos                                                                                            100% 5262KB   5.1MB/s   00:00    
mongo                                                                                             100% 3707KB   3.6MB/s   00:00    
mongoimport                                                                                       100% 7754KB   7.6MB/s   00:01    
mongodump                                                                                         100% 7773KB   7.6MB/s   00:00    
GNU-AGPL-3.0                                                                                      100%   34KB  33.7KB/s   00:00    
[root@localhost ~]# 

上傳后目標機器的目標目錄:
[root@localhost scptest]# ll
總計 488
drwxr-xr-x 3 root root   4096 03-15 09:33 mongodb
-rw-r--r-- 1 root root 490220 03-15 09:25 nginx-0.5.38.tar.gz
[root@localhost scptest]# 

說明:

    上傳本地目錄 /opt/soft/mongodb到遠程機器192.168.120.204/opt/soft/scptest的目(mu)錄(lu)中去

posted @ 2013-03-15 09:51  peida  閱讀(391051)  評論(7)    收藏  舉報