Serial communication on modern Linux

Connect to your console for troubleshooting with Tio, a Linux serial communication program.
123 readers like this.
computer servers processing data

Opensource.com

As a systems engineer, I spend a lot of time in data centers configuring servers and other computer equipment. Two of the items I keep in my toolkit are an RS-232 serial-to-USB converter and a standard DB-9 serial cable. These can be indispensable when you have no other way to access a device. You may need to deploy a new router that has not yet been configured for your network. You might need to troubleshoot a firewall appliance that has become inaccessible via SSH. In a "lights-out" environment, in particular, new servers may have a management card that needs to be initialized. A serial connection provides a direct path to a console for accomplishing these tasks.

I will use a Netgate appliance in this example. These are firewalls that have no mouse, keyboard, monitor, or other GUI capabilities. They're generally referred to as "headless."

Serial communications

To connect with a device over serial, you need hardware that supports the RS-232 protocol. This is typically a nine-pin DB-9 serial port, often labeled serial, comm, or console. Most older computers have at least one. Most servers still have them, but most laptops and desktops don't any longer.

Find the serial port

If your system doesn't already have a serial port, you'll need to use a converter like the one I mentioned. When you plug in the PL2303 converter to a USB port on your computer, the Linux kernel registers it as a USB TTY device.

There are several commands that you can use to query your system for its serial port configuration. Here are a few examples:

# dmesg |grep tty
[252464.891372] usb 6-1: pl2303 converter now attached to ttyUSB0

# setserial -g /dev/ttyUSB[0123]
/dev/ttyUSB0, UART: 16654, Port: 0x0000, IRQ: 0

# ls /dev/serial/by-id/
usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0

In my case, it detects the converter as a pl2303 converter (or a Prolific Technology USB serial controller).

Connect a serial cable

Connect your serial cable between the converter and the serial port on the device.

Log in with Tio

Over the years, I've used different tools, such as Minicom and Screen. Tio is a newer and simpler tool described as "a simple TTY terminal I/O application." It is available on most Linux distributions, FreeBSD, and OpenWRT, as well as a Snap package. I used the standard package tool to install version 1.32 onto my Red Hat Enterprise Linux 8.1 server:

# dnf info tio
# dnf install tio

Initialize the connection with the tio command. In my experience, Tio didn't need any advance configuration; it worked out of the box. Be sure that you have the correct device path, as shown above:

# tio /dev/ttyUSB0

# tio /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0

You can use the Ctrl+t command sequence to interact with Tio. For instance, Ctrl+t+? will list available commands, and Ctrl+t+q quits Tio and takes you back to your Linux command prompt.

Conclusion

We rarely think about or even use serial communications these days, but it is still useful. Data center people still need to be familiar with it.

Data centers can be remote, and once inside, you'll want to make sure you have all the proper tools. Besides a good Linux laptop, of course, I recommend the items above for managing those serial-enabled devices when necessary.

What to read next
Alan Formy-Duval Opensource.com Correspondent
Alan has 20 years of IT experience, mostly in the Government and Financial sectors. He started as a Value Added Reseller before moving into Systems Engineering. Alan's background is in high-availability clustered apps. He wrote the 'Users and Groups' and 'Apache and the Web Stack' chapters in the Oracle Press/McGraw Hill 'Oracle Solaris 11 System Administration' book.

14 Comments

Thanks Alan,
This is one of the best tech information articles - for me , that I have read in Opensource.com over the past three to four years. All other articles were also great.

Even though I am now retired, it was always frustrating to not be able to connect a laptop to server for configuration or analysis, as I had done twenty years ago by console.
Too late for me, but excellent information to pass along to new SysAdmins, particularly those coming from a purely Windows and PC environment.

Thanks for the kind review, I'm glad you enjoyed the article.

In reply to by W. Anderson (not verified)

Thank you for this article. I have been trying to figure out two situations and I hope you can provide some valuable input.

1 on a Mac you can use iterm2 which enables you to send text using a keystroke which has the password saved when you configured it . This will help you to save lots of time when you have to logon to 20-50 terminals a day so I'm a fan of this feature however I also use my Windows machine but I have not been able to find such an option on a windows environment.So.if you're aware of any terminal that might help then please let me know.

2. Many times I'm unable to connect to the Ubuntu servers due to VFS limit reached so only option is to reboot and when you have server years old then it's scary to reboot so I was wondering if there is still a way to connect to it and increase the limit by somehow connecting to it to prevent the reboot. Similarly , when I'm unable to ssh to the server , I want to be able to connect somehow remotely when I can't ssh remotely or locally.

Appreciate your input on these two things.

Thanks
Tushar

Just to be sure "tio" is not available in the Red Hat repositories. I think you installed it from EPEL. Is that correct?

Yes, as Seth confirmed. You will need to enable the EPEL repo for Red Hat Enterprise Linux. However, it is available in the standard repos on distributions such as Fedora (dnf install tio) and Ubuntu (apt install tio).

In reply to by John Call (not verified)

Is there a benefit to tio command line over something like putty? I've been using putty for years to handle any connection from telnet, ssh, or serial but am always open to interesting new software apps

Rob, I think to a large extent, it comes down to personal preference. Putty offers a fuller set of features, while tio is very focused. It is a quick install and is only ~36kb in size. But, I think it is a user choice.

In reply to by Rob C (not verified)

year 2020 but I still don't get how to use linux in my daily life

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.