1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > scp命令默认传输速度多大_每天一个linux命令(60):scp命令

scp命令默认传输速度多大_每天一个linux命令(60):scp命令

时间:2020-07-21 14:52:20

相关推荐

scp命令默认传输速度多大_每天一个linux命令(60):scp命令

scp是securecopy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读readonlysystem时,用scp可以帮你把文件移出来。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。

1.命令格式:

scp[参数][原路径][目标路径]

2.命令功能:

scp是securecopy的缩写,scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。linux的scp命令可以在linux服务器之间复制文件和目录。

3.命令参数:

-1强制scp命令使用协议ssh1

-2强制scp命令使用协议ssh2

-4强制scp命令只使用IPv4寻址

-6强制scp命令只使用IPv6寻址

-B使用批处理模式(传输过程中不询问传输口令或短语)

-C允许压缩。(将-C标志传递给ssh,从而打开压缩功能)

-p保留原文件的修改时间,访问时间和访问权限。

-q不显示传输进度条。

-r递归复制整个目录。

-v详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。

-ccipher以cipher将数据传输进行加密,这个选项将直接传递给ssh。

-Fssh_config指定一个替代的ssh配置文件,此参数直接传递给ssh。

-iidentity_file从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。

-llimit限定用户所能使用的带宽,以Kbit/s为单位。

-ossh_option如果习惯于使用ssh_config(5)中的参数传递方式,

-Pport注意是大写的P,port是指定数据传输用到的端口号

-Sprogram指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。

4.使用实例:

scp命令的实际应用概述:

从本地服务器复制到远程服务器:

(1)复制文件:

命令格式:

scplocal_fileremote_username@remote_ip:remote_folder

或者

scplocal_fileremote_username@remote_ip:remote_file

或者

scplocal_fileremote_ip:remote_folder

或者

scplocal_fileremote_ip:remote_file

第1,2个指定了用户名,命令执行后需要输入用户密码,第1个仅指定了远程的目录,文件名字不变,第2个指定了文件名

第3,4个没有指定用户名,命令执行后需要输入用户名和密码,第3个仅指定了远程的目录,文件名字不变,第4个指定了文件名

(2)复制目录:

命令格式:

scp-rlocal_folderremote_username@remote_ip:remote_folder

或者

scp-rlocal_folderremote_ip:remote_folder

第1个指定了用户名,命令执行后需要输入用户密码;

第2个没有指定用户名,命令执行后需要输入用户名和密码;

从远程服务器复制到本地服务器:

从远程复制到本地的scp命令与上面的命令雷同,只要将从本地复制到远程的命令后面2个参数互换顺序就行了。

实例1:从远处复制文件到本地目录

命令:

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

输出:

[root@localhost~]#cd/opt/soft/[root@localhostsoft]#ll总计80072

drwxr-xr-x12rootroot409609-2118:40fms3.5

drwxr-xr-x3rootroot409609-2117:58fms4.5

drwxr-xr-x10rootroot409610-3017:15jdk1.6.0_16

drwxr-xr-x10rootroot409609-1719:27jdk1.6.0_16.bak

-rwxr-xr-x1rootroot81871260-12-21jdk-6u16-linux-x64.bin

drwxrwxrwx2rootroot409609-2101:16mysql

drwxr-xr-x3rootroot409609-2118:40setup_file

drwxr-xr-x9rootroot409609-1719:23tomcat6.0.32

drwxr-xr-x9rootroot4096-08-14tomcat_7.0

[root@localhostsoft]#scproot@192.168.120.204:/opt/soft/nginx-0.5.38.tar.gz/opt/soft/root@192.168.120.204'spassword:

nginx-0.5.38.tar.gz100%479KB478.7KB/s00:00

[root@localhostsoft]#ll总计80556

drwxr-xr-x12rootroot409609-2118:40fms3.5

drwxr-xr-x3rootroot409609-2117:58fms4.5

drwxr-xr-x10rootroot409610-3017:15jdk1.6.0_16

drwxr-xr-x10rootroot409609-1719:27jdk1.6.0_16.bak

-rwxr-xr-x1rootroot81871260-12-21jdk-6u16-linux-x64.bin

drwxrwxrwx2rootroot409609-2101:16mysql

-rw-r--r--1rootroot4902-1509:11nginx-0.5.38.tar.gz

drwxr-xr-x3rootroot409609-2118:40setup_file

drwxr-xr-x9rootroot409609-1719:23tomcat6.0.32

drwxr-xr-x9rootroot4096-08-14tomcat_7.0

[root@localhostsoft]#

说明:

从192.168.120.204机器上的/opt/soft/的目录中下载nginx-0.5.38.tar.gz文件到本地/opt/soft/目录中

实例2:从远处复制到本地

命令:

scp-rroot@192.168.120.204:/opt/soft/mongodb/opt/soft/

输出:

[root@localhostsoft]#ll总计80556

drwxr-xr-x12rootroot409609-2118:40fms3.5

drwxr-xr-x3rootroot409609-2117:58fms4.5

drwxr-xr-x10rootroot409610-3017:15jdk1.6.0_16

drwxr-xr-x10rootroot409609-1719:27jdk1.6.0_16.bak

-rwxr-xr-x1rootroot81871260-12-21jdk-6u16-linux-x64.bin

drwxrwxrwx2rootroot409609-2101:16mysql

-rw-r--r--1rootroot4902-1509:11nginx-0.5.38.tar.gz

drwxr-xr-x3rootroot409609-2118:40setup_file

drwxr-xr-x9rootroot409609-1719:23tomcat6.0.32

drwxr-xr-x9rootroot4096-08-14tomcat_7.0

[root@localhostsoft]#scp-rroot@192.168.120.204:/opt/soft/mongodb/opt/soft/root@192.168.120.204'spassword:

mongodb-linux-i686-static-1.8.5.tgz100%28MB28.3MB/s00:01

README100%7310.7KB/s00:00

THIRD-PARTY-NOTICES100%78667.7KB/s00:00

mongorestore100%7753KB7.6MB/s00:00

mongod100%7760KB7.6MB/s00:01

mongoexport100%7744KB7.6MB/s00:00

bsondump100%7737KB7.6MB/s00:00

mongofiles100%7748KB7.6MB/s00:01

mongostat100%7808KB7.6MB/s00:00

mongos100%5262KB5.1MB/s00:01

mongo100%3707KB3.6MB/s00:00

mongoimport100%7754KB7.6MB/s00:00

mongodump100%7773KB7.6MB/s00:00

GNU-AGPL-3.0100%34KB33.7KB/s00:00

[root@localhostsoft]#ll总计80560

drwxr-xr-x12rootroot409609-2118:40fms3.5

drwxr-xr-x3rootroot409609-2117:58fms4.5

drwxr-xr-x10rootroot409610-3017:15jdk1.6.0_16

drwxr-xr-x10rootroot409609-1719:27jdk1.6.0_16.bak

-rwxr-xr-x1rootroot81871260-12-21jdk-6u16-linux-x64.bin

drwxr-xr-x3rootroot409603-1509:18mongodb

drwxrwxrwx2rootroot409609-2101:16mysql

-rw-r--r--1rootroot4902-1509:11nginx-0.5.38.tar.gz

drwxr-xr-x3rootroot409609-2118:40setup_file

drwxr-xr-x9rootroot409609-1719:23tomcat6.0.32

drwxr-xr-x9rootroot4096-08-14tomcat_7.0

[root@localhostsoft]#

说明:

从192.168.120.204机器上的/opt/soft/中下载mongodb目录到本地的/opt/soft/目录来。

实例3:上传本地文件到远程机器指定目录

命令:

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

输出:

上传前目标机器的目标目录:

[root@localhostsoft]#cdscptest/[root@localhostscptest]#ll总计0

[root@localhostscptest]#ll

本地机器上传:

[root@localhostsoft]#scp/opt/soft/nginx-0.5.38.tar.gzroot@192.168.120.204:/opt/soft/scptestroot@192.168.120.204'spassword:

nginx-0.5.38.tar.gz100%479KB478.7KB/s00:00

[root@localhostsoft]#

上传后目标机器的目标目录:

[root@localhostscptest]#ll总计484

-rw-r--r--1rootroot4902-1509:25nginx-0.5.38.tar.gz

[root@localhostscptest]#

说明:

复制本地opt/soft/目录下的文件nginx-0.5.38.tar.gz到远程机器192.168.120.204的opt/soft/scptest目录

实例4:上传本地目录到远程机器指定目录

命令:

scp-r/opt/soft/mongodbroot@192.168.120.204:/opt/soft/scptest

输出:

上传前目标机器的目标目录:

[root@localhost~]#cd/opt/soft/scptest/[root@localhostscptest]#ll总计484

-rw-r--r--1rootroot4902-1509:25nginx-0.5.38.tar.gz

[root@localhostscptest]#本地机器上传:

[root@localhost~]#scp-r/opt/soft/mongodbroot@192.168.120.204:/opt/soft/scptestroot@192.168.120.204'spassword:

mongodb-linux-i686-static-1.8.5.tgz100%28MB28.3MB/s00:01

README100%7310.7KB/s00:00

THIRD-PARTY-NOTICES100%78667.7KB/s00:00

mongorestore100%7753KB7.6MB/s00:00

mongod100%7760KB7.6MB/s00:01

mongoexport100%7744KB7.6MB/s00:00

bsondump100%7737KB7.6MB/s00:00

mongofiles100%7748KB7.6MB/s00:00

mongostat100%7808KB7.6MB/s00:01

mongos100%5262KB5.1MB/s00:00

mongo100%3707KB3.6MB/s00:00

mongoimport100%7754KB7.6MB/s00:01

mongodump100%7773KB7.6MB/s00:00

GNU-AGPL-3.0100%34KB33.7KB/s00:00

[root@localhost~]#

上传后目标机器的目标目录:

[root@localhostscptest]#ll总计488

drwxr-xr-x3rootroot409603-1509:33mongodb

-rw-r--r--1rootroot4902-1509:25nginx-0.5.38.tar.gz

[root@localhostscptest]#

说明:

上传本地目录/opt/soft/mongodb到远程机器192.168.120.204上/opt/soft/scptest的目录中去

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。