How to add serial line console to Linux server (Debian)

A serial line console allows you to run true headless servers, with no monitor or keyboard attached. You simply attach another computer (ie, laptop) to the serial terminal of the server with a cross-over cable and get a connection.


Following is taken from That is a good, consice article, and I only duplicated it here so it didn't get lost, which it appearntly did.

 edit /etc/default/grub and add the following lines:

GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

Note, /dev/ttyS0 is the first serial port on your server (often called COM1 on Windows oriented machines). To change to a differtn port, you should change the ttyS0 in the first line and the --unit=0 on the third line.

Run the command

update-grub # or update-grub2

from the command line to have the above changes take effect.

With system-d, that is all that is needed. You do not do the following as system-d assumes if you have a kernel serial console, you want it on the terminal after you log in also. Note that, without system-d, you can immediately start using the console after the following section, but with system-d you really need to reboot. Kind of silly actually.

For non-system-d systems, you should do the following. you must set init to give you a login prompt. You can do this by adding the lines below after the first one (the one with # this line is already here).

# make sure there is no ttyS0 line already in the file
# Serial console s0:2345:respawn:/sbin/getty -L 115200 ttyS0 vt102

When done, to activate the changes, issue the command

init q

which simply tells init to reread the inittab (or, you can simply reboot)


Speeds can be the max all of your devices support, ie find the slowest serial port and choose the fastest speed it supports. Common port speeds are: 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200 baud


Now, when you need to connect to this server and have no monitor/keyboard attached, bring up your Linux computer (laptop?) and plug in a USB to Serial connector if you don't have a serial port. Get a Null Modem cable and/or a Crossover cable to go from the laptop to the server.


I use minicom, but many people prefer different programs. You will need to figure out what your serial port is (hint,

tail -f /var/log/messages

when you plug in the USB to Serial connector), and set the parameters to 9600 baud, 8 bits, no parity, 1 stop bit, emulation type vt102. Example for minicom, port ttyUSB0, 115200 baud 8n1

minicom -D /dev/ttyUSB0 -b 115200 -o -8

 Note: on minicom, on my machines, I have to go into the configuration and specifically turn off Hardware and Software Flow Control. Instructions for minicom only (from inside minicom, after issuing the above command)

  • ^A -- Start Command Mode
  • ^O - cOnfigure minicom
  • Serial Port Setup
  • Option F: Turn off Hardware Flow Control
  • Option G: Turn off Software Flow Control
  • Enter (return from menu)
  • Exit

Connect to the server, press enter a couple of times and you should have it ready to go. If your server supports it and you also set serial console redirect in the BIOS, you can watch the entire boot process until a command prompt.


Last update:
2017-03-18 06:00
Average rating: 5 (1 Vote)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category