Enable Linux Serial Console login

Oren Oichman
5 min readDec 21, 2019

Why this article.

While working as a Linux System Admin I had many cases where I needed to work on a Server but the Server did not had internet access and I needed one.
to make things more difficult the ILO is dedicated to the Out Of band connection and can not disconnected…

The only option I had left available is to configure one of the COM ports of the Server as a Serial listening port and those connect through it.

Why did I write this document?

Although there are lots of documents available on the Internet that are dealing with Linux serial ports, most of them seemed to be either out of date, or missing good examples on how to use it.
I wanted consistent documentation on how to setup simple terminal access (with a few tweaks) via RS232C serial ports for RHEL 7.

Step 1: Check your system’s serial support

First, let’s make sure that your operating system recognizes serial ports in your hardware. You should make a visual inspection and make sure that you have one or more serial ports on your motherboard or add-in PCI card. Most motherboards have two built-in ports, which are called COM1: and COM2: in the DOS/Windows world. You may need to enable them in BIOS before the OS can recognize them. After your system boots, you can check for serial ports with the following commands:

dmesg | grep ttySttyS0 at 0x03f8 (irq = 4) is a 16550A
ttyS1 at 0x02f8 (irq = 3) is a 16550A

If your server does not have a serial port , you can always but a USB to SERIAL connect in a reasonable small price.

Now we need to set the serial post we found with a listening getty service:

stty -F /dev/ttyS0 speed 9600

What is a getty?

A getty is is a program that opens a tty port, prompts for a login name, and runs the /bin/login command. It is normally invoked by init.

agetty options explained:

  • -L force line to be local line with no need for carrier detect (when you have no modem).
  • -f alternative /etc/issue file. This is what a user sees at the login prompt.
  • -i do not display any messages at the login prompt.
  • 9600 serial line rate in bps. Set this to your dumb terminal or terminal emulator line rate.
  • ttyS0 this is the serial port identifier.
  • vt100 is the terminal emulation. You can use others, but VT100 is the most common or “standard”. Another widely used terminal type is VT102.

Possible serial line rates (sometimes called baud rates) for the 16550A UART:

  • 110 bps
  • 300 bps
  • 1200 bps
  • 2400 bps
  • 4800 bps
  • 9600 bps
  • 19,200 bps
  • 38,400 bps
  • 57,600 bps
  • 115,200 bps

I have tried all of these line rates. 9600 bps is generally O.K., and is a very common setting for networking hardware. 38,400 bps is the speed of the standard Linux console, so it is my second choice. If your dumb terminal or terminal emulator cannot handle 38,400 bps, then try 19,200 bps: it is reasonably speedy and you will not be annoyed.

Solaris Hardware Systems

if you are (for some reason) using a Solaris hardware then you do not need to run through this configuration , it should be priconfigured.

Step 2: Enable Serial port at boot.

Edit “/etc/sysconfig/grub”

Add to end of GRUB_CMD_LINELINUX, “console=ttyS0” Replace ttyS0 with your serial port.

Mine looks like this:

GRUB_CMDLINE_LINUX=”rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet console=ttyS0"

Run the following commands as root: Again replace ttyS0 with your serial port

Recreate the grub.conf configuration file :

grub2-mkconfig -o /boot/grub2/grub.cfg

And now make sure that getty is enabled for ttyS0 (for our example):

systemctl start getty@ttyS0

Console issued prompt :

Here was my custom issue file, /etc/issueserial. It uses escape sequences defined in the agetty manpage to add some useful information, such as the serial port number, line speed, and how many users are currently logged on:

Connected on \l at \b bps

Now, let’s make sure that the agetty process is listening on the serial ports:

[root@oscar root]$ ps -ef | grep agetty
root 958 1 0 Dec13 ttyS0 00:00:00 /sbin/agetty -L -f /etc/issueserial 9600 ttyS0 vt100
root 1427 1 0 Dec13 ttyS1 00:00:00 /sbin/agetty -L -f /etc/issueserial 38400 ttyS1 vt100

Step 3: tune the login.

-I have tested this setup with a WYSE dumb terminal, a Linux laptop running Minicom, and Windows 2000/XP laptops running HyperTerminal. They all worked just fine.

Terminal settings: should be 9600, N, 8, 1. Terminal emulation should be set to VT100 or VT102. Turn flow control off. If you want to use the 38,400 bps serial port on ttyS1, then your settings should be adjusted to 38400, N, 8, 1.

Cable: To connect a laptop to the serial port on the Linux host, you need to have a null-modem cable. The purpose of a null-modem cable is to permit two RS-232 DTE devices to communicate with each other without modems between them. While you can construct this yourself, a good, sturdy manufactured null-modem cable is inexpensive and will last longer.

If you insist on making the cable yourself, then check out Nullmodem.Com for the wiring and pinout diagram.

Connectors: Motherboard serial ports are typically male DB-9 connectors, but some serial ports use DB-25 connectors. You may need some DB-9 to DB-25 converters or gender-changers in order to connect to your terminal. For a typical laptop to server connection, a DB-9 null-modem cable should be sufficient.

Here is what you should see on the dumb terminal or terminal emulator:

Connected on ttyS1 at 115200bps
ServerName.vanemery.com login:

Note: If you want to be able to login via serial console as the root user, you will need to edit the /etc/securetty config file. The entries to add are highlighted in italic:



Step 4: Test serial port login.

There are several ways to login to a serial connection from the client side.

Some of the known clients are putty,minicom and cu (part of the “uuid” package).

The one that we are going to use now is screen,

I prefer screen for several reasons but mostly because it comfortable to use like the following example :

screen is able to connect to a serial port. It will connect at 9600 baud by default:

$ screen /dev/ttyS0

A different baud rate (e.g. 115200) may be specified on the command line.

$ screen /dev/ttyS0 115200

To end the session, press Ctrl+a followed by k.