标签搜索

目 录CONTENT

文章目录

Linux命令 之 rz和sz命令用法详解

沙漠渔
2022-08-03 20:29:01 / 0 评论 / 0 点赞 / 1,106 阅读 / 3,745 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-08-03,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

平时都是使用winscp等可视化工具来上传和下载服务器文件,但是有时候没有对应用户权限,通过sudo su切换用户的,无法使用winscp来上传,这就会有些麻烦了,于是需要使用rz和sz两个命令。

命令介绍

rz,sz是Linux/Unix同Windows进行ZModem文件传输的命令行工具。优点就是不用再开一个sftp工具登录上去上传下载文件。

其中:

  • sz:将选定的文件发送(send)到本地机器
  • rz:运行该命令会弹出一个文件选择窗口,从本地选择文件上传到Linux服务器

软件安装(centOS 7)

安装命令:

yum install lrzsz

命令使用(centOS 7)

从服务端发送文件到客户端:

sz filename

命令选项:

Usage: sz [options] file ...
   or: sz [options] -{c|i} COMMAND
Send file(s) with ZMODEM/YMODEM/XMODEM protocol
    (X) = option applies to XMODEM only
    (Y) = option applies to YMODEM only
    (Z) = option applies to ZMODEM only
  -+, --append                append to existing destination file (Z)
  -2, --twostop               use 2 stop bits
  -4, --try-4k                go up to 4K blocksize
      --start-4k              start with 4K blocksize (doesn't try 8)
  -8, --try-8k                go up to 8K blocksize
      --start-8k              start with 8K blocksize
  -a, --ascii                 ASCII transfer (change CR/LF to LF)
  -b, --binary                binary transfer
  -B, --bufsize N             buffer N bytes (N==auto: buffer whole file)
  -c, --command COMMAND       execute remote command COMMAND (Z)
  -C, --command-tries N       try N times to execute a command (Z)
  -d, --dot-to-slash          change '.' to '/' in pathnames (Y/Z)
      --delay-startup N       sleep N seconds before doing anything
  -e, --escape                escape all control characters (Z)
  -E, --rename                force receiver to rename files it already has
  -f, --full-path             send full pathname (Y/Z)
  -i, --immediate-command CMD send remote CMD, return immediately (Z)
  -h, --help                  print this usage message
  -k, --1k                    send 1024 byte packets (X)
  -L, --packetlen N           limit subpacket length to N bytes (Z)
  -l, --framelen N            limit frame length to N bytes (l>=L) (Z)
  -m, --min-bps N             stop transmission if BPS below N
  -M, --min-bps-time N          for at least N seconds (default: 120)
  -n, --newer                 send file if source newer (Z)
  -N, --newer-or-longer       send file if source newer or longer (Z)
  -o, --16-bit-crc            use 16 bit CRC instead of 32 bit CRC (Z)
  -O, --disable-timeouts      disable timeout code, wait forever
  -p, --protect               protect existing destination file (Z)
  -r, --resume                resume interrupted file transfer (Z)
  -R, --restricted            restricted, more secure mode
  -q, --quiet                 quiet (no progress reports)
  -s, --stop-at {HH:MM|+N}    stop transmission at HH:MM or in N seconds
      --tcp                   build a TCP connection to transmit files
      --tcp-server            open socket, wait for connection
  -u, --unlink                unlink file after transmission
  -U, --unrestrict            turn off restricted mode (if allowed to)
  -v, --verbose               be verbose, provide debugging information
  -w, --windowsize N          Window is N bytes (Z)
  -X, --xmodem                use XMODEM protocol
  -y, --overwrite             overwrite existing files
  -Y, --overwrite-or-skip     overwrite existing files, else skip
      --ymodem                use YMODEM protocol
  -Z, --zmodem                use ZMODEM protocol

从客户端上传文件到服务端:

rz

命令选项:

rz [选项]

选项说明:
-+, --append:将文件内容追加到已存在的同名文件
-a,--ascii:以文本方式传输
-b, --binary:以二进制方式传输,推荐使用
--delay-startup N:等待N秒
-e, --escape:对所有控制字符转义,建议使用
-E, --rename:已存在同名文件则重命名新上传的文件,以点和数字作为后缀
-p, --protect:对ZMODEM协议有效,如果目标文件已存在则跳过 -
-q, --quiet:安静执行,不输出提示信息
-v, --verbose:输出传输过程中的提示信息
-y, --overwrite:存在同名文件则替换
-X, --xmodem:使用XMODEM协议
--ymodem:使用YMODEM协议
-Z, --zmodem:使用ZMODEM协议
--version:显示版本信息
--h, --help:显示帮助信息
0
广告 广告

评论区