sz
Download files from a remote host
SYNOPSIS
sz [options] file ...
sz [options] -c command ...
PARAMETERS
-a
Perform an ASCII (text) transfer, converting newline characters as appropriate for the receiving system.
-b
Perform a binary transfer (default for ZMODEM and YMODEM).
-e
Escape all control characters. Useful when the serial line is not 8-bit clean.
-k
Keep the original filename case on the destination system.
-p
Protect existing destination files; do not overwrite them.
-q
Run in quiet mode, suppressing verbose output and progress indicators.
-r
Resume an interrupted transfer. Applicable only for ZMODEM.
-v
Enable verbose output, showing transfer progress and status messages.
-w N
Set the ZMODEM window size to N bytes, controlling the amount of data sent before acknowledgment.
-y
Force overwrite of existing destination files (default behavior).
-X
Use the XMODEM protocol for file transfer.
-Y
Use the YMODEM protocol for file transfer (batch mode XMODEM).
-Z
Use the ZMODEM protocol for file transfer (default and recommended).
--version
Display version information and exit.
--help
Display a help message and exit.
DESCRIPTION
sz is a utility from the lrzsz package, designed for reliable file transfers over serial lines or similar point-to-point connections, such as pseudo-terminals (e.g., when connecting via ssh and needing to transfer a file using a terminal emulator's ZMODEM support). It primarily uses the ZMODEM protocol, which offers error checking, crash recovery, and efficient block transfers, making it suitable for less reliable connections. It can fall back to YMODEM or XMODEM if ZMODEM is not supported by the receiving end.
sz is typically paired with rz (receive ZMODEM) on the remote side. It's particularly useful in scenarios where scp or sftp might not be available or practical, such as when interacting with embedded systems, legacy devices, or during initial system setups before network services are fully configured. The command initiates a transfer, and a compatible terminal emulator on the local machine (running rz automatically or manually) receives the file.
CAVEATS
File transfers with sz heavily rely on the capabilities of the terminal emulator on the receiving side to detect and handle ZMODEM sequences. It is generally not suitable for network file transfers where more robust and secure protocols like SCP or SFTP are available and preferred. Performance can be limited by serial line speeds or pseudo-terminal buffer sizes. Misconfiguration of terminal settings via stty can also interfere with transfers.
ZMODEM USAGE FLOW
When using sz, the typical workflow involves:
1. Running sz on the remote Linux machine with the file(s) to send.
2. A compatible terminal emulator (e.g., SecureCRT, iTerm2 with an iterm2-zmodem plugin, minicom) on the local machine detects the ZMODEM initiation sequence.
3. The terminal emulator automatically or prompts to start its rz equivalent (or a built-in ZMODEM receiver) to begin receiving the file.
This allows file transfers even when standard network protocols like SCP or SFTP are not configured or available, relying purely on the terminal session.
HISTORY
The sz command is part of the lrzsz package, which implements the ZMODEM, YMODEM, and XMODEM file transfer protocols. These protocols were developed in the 1980s by Chuck Forsberg and others, primarily for reliable data transmission over noisy analog telephone lines via modems. ZMODEM, in particular, offered significant advancements like crash recovery, larger block sizes, and efficient error checking compared to its predecessors. While originally designed for serial port communication, lrzsz found a new life in server administration, allowing file transfers over SSH connections through terminal emulators that support ZMODEM, even when direct scp or sftp access might be restricted or inconvenient. Its continued relevance highlights its robustness for 'last resort' or specific legacy transfer needs.