I work with an RS-232 device via GNU screen.

$ screen /dev/ttyUSB0 115200

At some point I need to send a local file to the device using either the xmodem or kermit protocol. On Windows I use TeraTerm which has a corresponding menu item. How can I achieve this in GNU screen?

5 Answers 5


the best way to pass a file through xmodem is to use sx. In debian this application is part of 'lrzsz' package.

In debian:

apt-get install screen lrzsz

screen /dev/ttyUSB0 115200

Then press Ctrl-A followed by : and type:

exec !! sx yourbinary.bin

This will send the file to ttyUSB0 over xmodem protocol

  • Can this operation be executed non-interactively, either with screen cu or any other package?
    – Vorac
    Commented Oct 29, 2015 at 8:06
  • 3
    @Vorac you can always do sx binary.bin | socat FILE:/dev/ttyUSB0,b115200,raw -
    – GnP
    Commented Mar 24, 2016 at 19:59
  • 3
    How to give receive command Give your local XMODEM receive command now Commented Jul 31, 2017 at 10:10
  • Where is that package maintained? I can't find it.
    – not2qubit
    Commented Jul 12, 2019 at 9:24

If you want to use zmodem you have to set the zmodem option to pass, if your screen session is already running, press CTRL+A : and just enter zmodem pass . To send the data just use the sz command from the lrzsz package.

If you want to receive data via screen you have to set the value to catch.

  • zmodem catch is an option I've been search for for ages! Good riddance, minicom. Commented Apr 11, 2017 at 2:48

I was in need to automate the serial transfer of a .bin file to an xbee with xmodem so I used this sloppy bash code:

echo "Starting connection..."
screen -d -m -S uart_con /dev/ttyO1 115200
sleep 1
screen -S uart_con -X stuff 'F'$(echo -ne '\015')
sleep 1
screen -S uart_con -X exec \!\! sz -X /home/file_directory/example.abs.bin
echo "now transfering... "
sleep 20
pkill screen

The third line sends a command to the other side(xbee) to start listening for a file transfer. So you are probably good with just:

screen -d -m -S uart_con /dev/ttyUSB0 115200
screen -S uart_con -X exec \!\! sz -X /path_to_file/example.file

If you are trying to do this through screen on OSX, you can follow the procedure laid out by user32704 with some small modifications. You will need to first build lrzsz from source, which can be found here:


Then, instead of exec !! sx yourbinary.bin you should use:

exec !! lsz -X yourbinary.bin
  • 6
    brew install lrzsz Commented Sep 2, 2016 at 10:34
  • sudo port install lrzsz
    – miken32
    Commented Sep 20, 2016 at 17:36

Quoting AltairClone.com Using “screen” as terminal emulator under UNIX/LINUX https://altairclone.com/downloads/Using%20SCREEN%20as%20terminal%20emulator.pdf :


Using “screen” as terminal emulator under UNIX/LINUX

To start a session, type “screen” followed by the serial device name and baud rate:

Unix prompt> screen /dev/ttyUSB0 9600

To get to screen commands, type ctrl-a followed by a command character. To see a list of commands, type ctrl-a ? (no space after ctrl-a, ctrl is not held for ?).

To exit the current screen, type ctrl-a k

To exit all screens (if multiple started by mistake), type ctrl-a
Some versions of screen may require ctrl-a ctrl-\

To send a file with XMODEM, type ctrl-a : (colon is the command character), then at the prompt, type:

exec !! sx [-a] filename

(Use –a to convert single new-line characters to CR/LF pairs.)

To receive a file with XMODEM, type ctrl-a : (colon is the command character), then at the prompt, type:

exec !! rx [-a] filename

(Note: The first ! tells sx/rx to get stdin through screen’s input connection. The second ! tells sx/rx to route stdout through screen’s output connection.)

To change the baud rate prior to an XMODEM transfer, type ctrl-a : (colon is the command character), then at the prompt, type:

exec !! stty new_baud_rate

Alternatively, exit screen by typing ctrl-a k, then re-start screen at the new baud rate (e.g.):

Unix prompt> screen /dev/ttyUSB0 new_baud_rate

To simply send an ASCII or binary file (i.e., XMODEM not used), type ctrl-a : (colon is the command character), then at the prompt, type:

exec !! cat filename


You must log in to answer this question.