Identifying and managing serial devices on a Linux system is a fundamental skill for system administrators, embedded developers, and hardware enthusiasts. Whether you are connecting a modem, a GPS receiver, a PLC controller, or a debugging console, the operating system must correctly recognize the physical interface. This process begins with understanding how the Linux kernel enumerates hardware and exposes these communication channels to the user space.
Understanding the Serial Port Architecture
Modern Linux systems handle serial devices through a layered architecture that abstracts the physical hardware. Traditional physical serial ports, historically labeled COM1 or COM2 in other operating systems, are represented as device files within the /dev directory. These files, typically named /dev/ttyS* for ISA ports or /dev/ttyUSB* for USB-to-serial converters, serve as the interface for all user-space applications. The kernel drivers managing these ports handle the low-level signal processing, allowing applications to communicate as if they were interacting with a simple file descriptor.
Physical vs. Virtual Serial Ports
It is important to distinguish between physical and virtual serial ports when listing devices. Physical ports are directly wired to the motherboard’s UART (Universal Asynchronous Receiver-Transmitter) chip. In contrast, virtual ports are created by USB-to-serial adapter chips, such as those from FTDI, Prolific, or Silicon Labs. These adapters translate USB data packets into the standard RS-232 signal timing. Consequently, the command used to list these devices often differs based on whether you are looking for hardware UART connections or USB-mediated serial communication.
Using the ls Command
The most direct method to list available serial ports involves querying the /dev directory. By listing the contents matching the specific naming pattern, you can quickly identify active interfaces. The ls command provides a straightforward way to verify device presence before attempting communication.
ls /dev/ttyS* – Lists standard UART serial ports.
ls /dev/ttyUSB* – Lists USB serial adapters.
ls /dev/ttyACM* – Lists modems and devices using the ACM (Abstract Control Model) protocol.
While this method is effective, it only shows the existence of the device node. It does not confirm if the device is currently powered, properly configured, or if the necessary driver is loaded. For more dynamic information, system tools are required.
Leveraging System Tools for Enumeration
For a more detailed and reliable overview, the dmesg and lsblk commands provide context that static file listing cannot. The dmesg command prints the kernel ring buffer, which contains the initialization messages generated when the system boots and when hardware is plugged in. Searching this log for "tty" reveals which drivers detected and registered serial ports.
The setserial utility reports and configures serial port information. When executed without arguments, such as setserial -g /dev/ttyS* , it displays the I/O address, interrupt request (IRQ), and type of each detected serial port. This level of detail is invaluable for troubleshooting conflicts in legacy systems where hardware resources must be manually managed.
Advanced Detection with lsserial
On distributions utilizing the util-linux package, the lsserial command offers a hierarchical view of serial devices. This tool queries the kernel directly via the sysfs filesystem, presenting a clean summary of the port name, I/O address, IRQ, and UART type. The structured output makes it easier to parse programmatically compared to grepping raw dmesg output.