Debian Linux: Set a Serial Console

How do I set up a serial console on Debian Linux HP server for troubleshooting and login purpose?

To setup a serial console you need to edit the following files under Debian Linux:

  1. /boot/grub/menu.lst or /etc/default/grub (recommended for grub2)
  2. /etc/inittab
  3. /etc/securetty

Our Setup

You can list your working serial port under Linux as follows:
# setserial -g /dev/ttyS[0123]
Sample outputs:

/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3

/dev/ttyS0 (COM1) is detected and working serial console under Linux. For testing purpose, I’m going to set baud rate to 19200 and terminal type to vt100.

Grub Configuration (Grub2)

Edit /etc/default/grub, enter:
# vi /etc/default/grub
Append / modify as follows:

GRUB_CMDLINE_LINUX='console=tty0 console=ttyS0,19200n8'
GRUB_SERIAL_COMMAND="serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1"

Save and close the file. Next run the following command to generate a grub2 config file /boot/grub/grub.cfg :
# update-grub

A Note About Grub Legacy (older version)

If you are not using GRUB2 update /boot/grub/menu.lst (grub legacy) with kernel line as follows with console port, and baud rate:

title           Debian GNU/Linux, kernel 2.6.32-5-486
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.32-5-486 root=UUID=b598f856-2a2a-46d5-b60a-95826cfc7bf6 ro console=ttyS0,19200 earlyprint=serial,ttyS0,19200
initrd          /boot/initrd.img-2.6.32-5-486

Save and close the file.

/etc/inittab Configuration

Edit /etc/inittab, enter:
# vi /etc/inittab
You need put a getty on a serial line for a terminal:

T0:23:respawn:/sbin/getty -L ttyS0 19200 vt100

Save and close the file.

/etc/securetty Configuration

Edit /etc/securetty, enter:
# vi /etc/securetty
Make sure UART serial ports /dev/ttyS0 is listed:


Save and close the file. Now, you can reboot the server for testing purpose.

How Do I Connect Using a Serial Console?

You need to use the minicom command, which is a communication program that runs under most unices. You can install minicom as follows on your Debian / Ubuntu desktop system:
# apt-get install minicom
For rpm based distro such as RHEL / Fedora / CentOS Linux, enter:
# yum install minicom
Run minicom as follows to create a configuration file:
# minicom -s -c on
Press [down] key and select Serial port setup:

Fig.01: Setting up minicom serial port

  1. Press A to setup serial device name such as /dev/ttyS0
  2. Press E to setup Bps/Par/Bits (baud rate)
  3. Press [ESC] to exit
  4. From menu select “Save setup as DFL”
  5. Exit

Alternatively, you can create minicom config DFL file as follows:
# cat /etc/minicom/minirc.dfl
pu port /dev/ttyS0
pu baudrate 19200
pu bits 8
pu parity N
pu stopbits 1
pu rtscts No

Save and close the file. To connect to a serial console simply type the minicom command as follows:
# minicom
Sample outputs:

Fig.02: Minicom in action

How Do I Connect From MS-Windows XP / 2000 / Vista / 7 Desktop System?

You can use the HyperTerminal or putty client as described here.

How Do I Connect To a Serial Console Over IP Network?

You need to use the KVM over IP client as described here or use the ipmitool command line tool for serial console redirection over IP (LAN/WAN). It is highly recommend that you access server over a serial console using some sort of VPN to encrypt all traffic.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • yoander Jan 26, 2011 @ 18:49

    Hey vivek, you could write Debian GNU / Linux instead of Debian Linux

    • yoander Aug 9, 2011 @ 21:43

      derpa derp derp as derpa gnu derp

  • Bob Jul 30, 2013 @ 23:23

    The images are down :(

  • Mike Schmitz Dec 31, 2014 @ 19:06

    You might remind people that they need a null-modem connector to make this work.

  • Brian Jul 17, 2016 @ 22:36

    I use the getty command ‘/sbin/getty -L ttyUSBupper 9600 vt100’ , and success prompt to upper USB , but why I put in

    /etc/inittab :

    T1:23:respawn:/sbin/getty -L ttyUSBupper 9600 vt100

    It just can not work while the Raspberry pi3 boot up ?

    Brian Lai

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum