工具:xshell
一、使用rz命令进行windows和linux服务器文件之间的上传和下载
1.1 使用rz命令将windows中的文件上传到Linux服务器
在linux服务器中使用安装lrzsz:yum install lrzsz
[root@VM_0_10_centos etc]# yum install lrzsz
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): epel/7/x86_64/group_gz | 95 kB 00:00:00
(2/5): extras/7/x86_64/primary_db | 206 kB 00:00:00
(3/5): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(4/5): updates/7/x86_64/primary_db | 4.5 MB 00:00:00
(5/5): epel/7/x86_64/primary_db | 6.9 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================
Installing:
lrzsz x86_64 0.12.20-36.el7 os 78 k
Transaction Summary
===================================================================================================================================================
Install 1 Package
Total download size: 78 k
Installed size: 181 k
Is this ok [y/d/N]: y
Is this ok [y/d/N]: y
Downloading packages:
lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lrzsz-0.12.20-36.el7.x86_64 1/1
Verifying : lrzsz-0.12.20-36.el7.x86_64 1/1
Installed:
lrzsz.x86_64 0:0.12.20-36.el7
Complete!
先看下test
目录下有什么文件:
[root@VM_0_10_centos test]# ll
total 8
-rw-r--r-- 1 root root 3890 Jun 27 21:17 1.sql
-rw-r--r-- 1 root root 70 Jun 1 16:26 test.php
输入rz
命令吊起了选择文件的界面,选择1.txt
上传到服务器的test
目录:
再次查看test
目录中的所有文件:
[root@VM_0_10_centos test]# ll
total 12
-rw-r--r-- 1 root root 3890 Jun 27 21:17 1.sql
-rw-r--r-- 1 root root 1978 Jul 3 21:08 1.txt
-rw-r--r-- 1 root root 70 Jun 1 16:26 test.php
1.2 使用sz
命令将linux服务器中的文件下载到windows
输入命令sz 路径/文件名
调起要保存到的路径,我将其保存到桌面上:
[root@VM_0_10_centos test]# sz /www/wwwroot/test/1.txt
再次看桌面,已经有了1.txt
这个文件:
二、使用scp实现linux服务器到linux服务器之间的文件传输
2.1 一台linux服务器传输文件
到另一台linux服务器
服务器1中:
[root@iz579n4gtfbecpz wwwroot]# cd mycode
[root@iz579n4gtfbecpz mycode]# ll
total 4
-rw-r--r-- 1 www www 541 Dec 7 2018 tu.php
将服务器1中的tu.php
传输到服务器2
中:
[root@iz579n4gtfbecpz ~]# scp /www/wwwroot/mycode/tu.php [email protected]:/www/wwwroot/test/
[email protected]'s password:
tu.php 100% 541 10.1KB/s 00:00
服务器2
中查看:
[root@VM_0_10_centos test]# ll
total 16
-rw-r--r-- 1 root root 3890 Jun 27 21:17 1.sql
-rw-r--r-- 1 root root 1978 Jul 3 21:08 1.txt
-rw-r--r-- 1 root root 70 Jun 1 16:26 test.php
-rw-r--r-- 1 root root 541 Oct 5 13:09 tu.php
发现,tu.php
已经从服务器1中传输过来了。
2.2 一台linux服务器传输目录
到另一台linux服务器
服务器1
中:
[root@iz579n4gtfbecpz wwwroot]# scp -r /www/wwwroot/mycode/ [email protected]:/www/wwwroot/test/
[email protected]'s password:
tu.php 100% 541 16.1KB/s 00:00
服务器2
中:
[root@VM_0_10_centos test]# ll
total 20
-rw-r--r-- 1 root root 3890 Jun 27 21:17 1.sql
-rw-r--r-- 1 root root 1978 Jul 3 21:08 1.txt
drwxr-xr-x 2 root root 4096 Oct 5 13:20 mycode
-rw-r--r-- 1 root root 70 Jun 1 16:26 test.php
-rw-r--r-- 1 root root 541 Oct 5 13:09 tu.php
这时,mycode
文件夹已经传输过来。