I have a Linux system that has USB ports, no RS-232 port. I would like to be able to plug in a USB cable into the Linux system and the other end of the USB cable into my PC, which happens to be running Windows 11 and has PuTTY.

The cable I need create I can do, it will be little more than a FTDI USB cable at one end and a simple USB connector at the other. Where I use a USB connector rather than a RS0-232 connector, and the FTDI TX <> RX USB connector, FTDI RX <> TX USB connector, and common GND of course. I will have to ensure 3.3v or 5v signaling depending on what the FTDI chip can handle. Regardless of the physical cabling, really a null modem like, here is the issue, the real question, the Software configuration?

How do I configure the Linux system to establish a getty session to a specific USB port? Lets assume I can figure that out, so it is /dev/ttyUSB0 or such for the sake of discussion?

The Linux system is systemd based, so I understand it, I can't use a UDEV rule/script to setup the terminal session, because it would be a long lived child or grandchild process.

And I know the this terminal session will not be a true mimic of the system console, that is ok, I just need a session once the system is up.

I know this is a long lead up to the question, thanks for the forbearance. It is the software configuration on the Linux system, that I really need the help with.

1 Answer 1


As I understood the intention is to make a serial console port out of USB port.

First of all, to make such a cable you need two converters. Each computers USB port must be supplied with USB-to-UART converter, and converters need to be connected back to back, RX of one to TX of another. And connect grounds together, but probably it is better to have a galvanic isolation (a pair of optocouplers, one for each direction TX→RX) to eliminate any possible ground loops. In the end you'll have a USB-to-USB null-modem cable, which looks like a serial port when either end connected into the computer, and when both ends plugged, those serial ports appear to be connected with the standard null modem cable.

Next, you need to run a systemd getty service on this USB serial port. If you can afford leaving the cable always connected to the Linux machine, you may simply enable the serial-getty@ttyUSB0 service:

systemctl enable [email protected]

If you rather want to be allowed to plug and pull it after system is started, you need to set up systemd and udev to play together to start this service whenever the USB-to-serial device is plugged in, and to kill the service when it is pulled out.

For this, you make your device depend on the service. Add udev rule to add the dependency dynamically using SYSTEMD_WANTS environment variable:

ACTION=="add", SUBSYSTEM=="tty", KERNEL=="ttyUSB*", ENV{SYSTEMD_WANTS}+="serial-getty@%k.service"

The rule could be put into /etc/udev/rules.d/99-ttyUSB.rules. %k means "take kernel device name" which is something like ttyUSB0.

Use udev tools to figure out the most convenient filter for udev rule; this one is very broad and will take over any device that looks like USB-serial and run getty on there. Even if it is really a modem which appears as two ttyUSB's! Look, for example, here for details; also watch out for caveats.

Now, on my Debian system it logs into the /var/log/daemon.log:

Dec  6 16:31:39 uc-s4m75657 systemd[1]: Started Serial Getty on ttyUSB0.
Dec  6 16:31:41 uc-s4m75657 ModemManager[632]: <info>  [base-manager] couldn't check support for device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-7': not supported by any plugin
Dec  6 16:32:27 uc-s4m75657 systemd[1]: [email protected]: Succeeded.
Dec  6 16:32:27 uc-s4m75657 systemd[1]: Stopped Serial Getty on ttyUSB0.

And, of course, a /bin/login process associated with ttyUSB0 appears and disappears.

See also this answer.

If you need to limit the set of possible serial speeds on which it is allowed to sync, you may do that using the override file. Run systemctl edit [email protected] and add:

ExecStart=-/sbin/agetty 115200 %I $TERM

or whatever speed you want it to use, make sure your USB-to-serial adapter supports it.

  • I can actually build such a cable/interface, I have optocoupler ICs and the other components. However, for anyone interested, the following does not appear to have isolation ftdichip.com/products/usb-nmc-2-5m. But hackday.io has details on what you qualify hackaday.io/project/174384-isolated-usb-null-modem. Which appears to have full isolation. Can't wait to try this! Dec 7, 2022 at 15:16
  • Honestly, I didn't checked all the features of FTDI cable. In the meantime, you can already set up the systemd/udev part of the configuration, because that only requires you to have an USB-serial converter ("a half" of a cable). Dec 7, 2022 at 17:08
  • About hakaday project: it seems to use triple-channel optocouplers to connect CTS/RTS and DTR/DSR too. That way you'll be able to have hardware flow control over that cable. For simple shell usage it is not very worthy, but if you happen to run something like PPP over that cable (and IP over it), it will become handy. Dec 7, 2022 at 17:13
  • Right, I purchased the hackaday unit for now, but plan to build my own in due course. since I will need a few of these. There are a couple of different ways to do the isolation, opto, RF gap, etc. I have many micro-controllers that I have to update frequently, and doing so over wifi is painful at times, so that will be the media use case. Dec 8, 2022 at 19:17
  • I have a mini PC and laptop that will configured to serve the updates, as you noted, so I can simply walk up the installed micro-controller, connect to USB port on the micro-controller (configure as noted above) and with a few steps have console control as Dec 8, 2022 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .