How to use rz/sz tool for file transfer in Linux

  
                

In Linux, using the rz/sz tool to transfer files between Linux and Windows, how do you use the rz/sz tool? The following small series will introduce you how to use rz/sz tools for file transfer under Linux. Let's learn together.

Generally speaking, most Linux servers are remotely logged in and managed through the ssh client. After using ssh to log in to the Linux host, how can I quickly interact with the local machine, that is, upload And download files to the server and local;

Two commands related to ssh can provide very convenient operations:

sz: Send the selected file to the local machine

rz: Run this command will pop up a file selection window, upload the file from the local selection to the server (receive)

rz, sz is the command line for Linux/Unix and ZModem file transfer with Windows. Tools

The telnet/ssh client (such as SecureCRT) that supports ZModem on the Windows side

Run the command rz, that is, receive the file, SecureCRT will pop up the file selection dialog box, after selecting the file Close the dialog box, the file will be uploaded to the current directory

Note: There will be two problems with rz alone: ​​upload interruption, upload file change (md5 is different), the solution is upload is rz -be, and removes the dialog box & ldquo; Upload files as ASCII & rdquo; check before.

-b binary Upload and download in binary mode, without interpreting characters ascii

-e Force escape all control characters, such as Ctrl+x, DEL, etc.

Run command Sz file1 file2 is to send files to windows (the saved directory is configurable) more convenient than the ftp command, and the server does not need to open the FTP service

PS: Linux two rz/sz gadgets Install lrzsz-xxxx.rpm.

Of course, you can also set the directory:

Set the upload and download default directory in SecureCRT

options–"session options–" file transfer And the downloaded directory

The rest of you only need to log in to the Linux terminal with SecureCRT:

Send the file to the client: sz filename

zmodem can be started by itself.

Uploading files from the client to the linux server:

As long as the server executes: rz

Then select the file to send in SecureCRT, the protocol zmodem

File transfer tool rz/sz (lrz/lsz) between Linux and Windows Introduction

[What is rz/sz (lsz/lrz)]

Simply put, it can be very convenient Use these two sz /rz tools to achieve file transfer (send and receive) between Linux and Windows, the speed is about 10KB /s, suitable for small and medium files. Rz/sz transfers data via the Zmodem protocol.

[Why use rz/sz]

Common file sharing methods between Linux and Windows, mainly to establish nfs file sharing, and tftp and other methods, but very troublesome And if it is just a small file (tens of K, a few hundred K), then directly using rz/sz, it is extremely convenient. Large files, you still have to consider the above, other sharing methods, after all, rz /sz speed is only about 10K, the transmission of large files will be exhausting. . .

[How to use]

(1) Under Windows, use SecureCRT (or Windows HyperTerminal) to connect the Com port to the development board, or connect to the Linux server using ssh and other protocols. .

(2) On the Linux side, after installing the rz/sz (lrz/lsz) tool (in embedded development, most of the compiled rz/sz tools have been put into rootfs, ordinary Linux System, if not, you can download the source code, install it yourself), you can run rz/sz directly, and realize the file transfer between Windows:

A, copy/download files from windows to Linux (development Board):

After running rz, the file selection dialog box under WIndows will pop up automatically. After selecting the corresponding file, add it, then confirm, start the transfer, and copy the files in windows to Linux.

B. Copy the files in Linux to a folder in Windows:

Execute sz file_name to copy the file_name of the current Linux folder to the corresponding directory of Windows. , where the Windows directory is set by the tool you are currently running.

Here I am using SecureCRT, the specific way to change the default path of rz upload /sz download:

Right click on the current session session -> Session Options -> Terminal -> Xmodem /Zmodem ->Directories :

Upload : The path you want to set

Download: The path you want to set

The following is a supplement:

[General for use SecureCRT ssh]

yum install lrzsz -y

Note: after RHEL mounting system may be used directly rz sz

method two: source file Compile method

Install configuration for centos xx version lrzsz

Copy the code as follows:

mkdir -p /usr/src/tools

cd /home /ryan/tools

wget http://down1.chinaunix.net/distfiles/lrzsz-0.12.20.tar.gz

tar zxvf lrzsz-0.12.20.tar.gz< Br>

cd lrzsz-0.12.20

. /configure --prefix=/usr/local/lrzsz

make

make install

cd /usr/bin

ln -s /usr/Local/lrzsz/bin/lrz rz

ln -s /usr/local/lrzsz/bin/lsz sz

rz

Method 3: rpm installation:

rpm ivh lrzsz-x.rpm (to find it on the CD)

Skip here.

Program example: A student encounters rz, sz upload and download problems

rz normal, sz can not download files to the local. But the students are still confused, I don’t know why.

Problem and Resolution Process:

[code]

[root@potatoes ~]# which sz

/usr/bin/sz

[root@potatoes ~]# ll /usr/bin/sz

lrwxrwxrwx 1 root root 24 Dec 6 2010 /usr/bin/sz -" /usr/local/lrzsz/bin/lrz< Br>

#===” It is obvious here that sz links to sz -" /usr/local/lrzsz/bin/lrz. It should be lsz

[root@potatoes ~]# rm -f /usr/bin/sz

[root@potatoes ~]# which sz

/usr/bin /which: no sz in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin :/root/bin)

[root@potatoes ~]# ll

total 52

-rw------- 1 root root 994 Dec 6 2010 Anaconda-ks.cfg

-rw-r--r-- 1 root root 26403 Dec 6 2010 install.log

-rw-r--r-- 1 root root 4369 Dec 6 2010 install.log.syslog

[root@potatoes ~]# ln -s /usr/local/lrzsz/bin/lsz /usr/bin/sz

#=== Modify the link sz -" /usr/local/lrzsz/bin/lsz

[root@potatoes ~]# /usr/local/lrzsz/bin/lsz install.log

rz

Starting zmodem transfer. Press Ctrl+C to cancel.

Transferring install.log. .

100% 25 KB 25 KB/s 00:00:01 0 Error

[root@potatoes ~]#ll /usr/bin/sz

lrwxrwxrwx 1 root Root 24 Jun 11 08:00 /usr/bin/sz -" /usr/local/lrzsz/bin/lsz

[root@potatoes ~]# ll

total 52

-rw------- 1 root root 994 Dec 6 2010 anaconda-ks.cfg

-rw-r--r-- 1 root root 26403 Dec 6 2010 install.log< Br>

-rw-r--r-- 1 root root 4369 Dec 6 2010 install.log.syslog

[root@potatoes ~]# sz install.log

rz

Starting zmodem transfer. Press Ctrl+C to cancel.

Transferring install.log. .

100% 25 KB 25 KB/s 00:00:01 0 Error

OK.

The above is the use of rz/sz tool for file transfer in Linux. The transfer speed of this method is slow, it is not suitable for large files, it is recommended to use small and medium file transfer.

Copyright © Windows knowledge All Rights Reserved