Linux & Open Source » Enabling a Serial Port Console: getty systemd


Using the serial port to login is a good way to get access to a device that doesn't have a network connection. This could be a small embedded Linux computer.

Raspberry Pi

enable_uart=1

On a Raspberry Pi you can edit /boot/config.txt and add this at the bottom. Then reboot. More details can be found here.

Linux devices with systemd

sudo nano /lib/systemd/system/[email protected]

First we need to edit the serial-getty service to set the correct bard rate.

# Edit this line
ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM

# To This
ExecStart=-/sbin/agetty 115200 %I $TERM

Set this to the bard rate that you wish to use. This should be the same at the computer is using at the other end.

systemctl daemon-reload

# For a USB serial adaptor
systemctl enable [email protected]

# For a built in serial port /dev/ttyS0
systemctl enable [email protected]

You can now log in using the serial console on /dev/ttyUSB0 or /dev/ttyS0

  1. Connect another computer to it using a NULL modem cable.
  2. Then open a terminal emulator such as minicom.
  3. Set the baud rate and port.
  4. Press enter a few times and you should then see a login prompt.