setserial
Configure serial port parameters
TLDR
Print all information about a specific serial device
Print the configuration summary of a specific serial device (useful for printing during bootup process)
Set a specific configuration parameter to a device
Print the configuration of a list of devices
SYNOPSIS
setserial [ -v ] [ -a ] [ -G ] [ -g ] [ -b ] [ -X ] <device> [ <parameters> ... ]
setserial -t <device>
setserial -V
PARAMETERS
-v
Verbose mode. Displays more detailed information about the serial port configuration, including any errors.
-a
Display all available information for the specified device, or list details for all detected serial devices if no device is specified.
-G
Graphical output mode, intended for displaying information in a more structured, table-like format (less commonly used today).
-g
Print only the device names of the configured serial ports, one per line, useful for scripting.
-b
Report the current baud rate settings for the specified device. Note that the actual communication speed is often managed by stty.
-X
Expert mode. Displays raw, numeric values for internal serial port settings, useful for advanced debugging.
-t
Test mode. Performs basic tests on the serial port, such as checking for IRQ conflicts or the presence of a UART chip.
-V
Display the version information for the setserial utility.
DESCRIPTION
setserial is a Linux command-line utility used to examine and configure the parameters of traditional serial ports (UARTs). It allows administrators to view and modify settings such as the I/O base address, IRQ number, port type (e.g., 16550A, 16450), and various flags like skip_test or auto_irq. Historically, it was crucial for optimizing serial port performance and ensuring correct operation for devices such as modems, serial consoles, and industrial equipment connected via physical COM ports. While it can retrieve real-time port status, its ability to persistently configure ports usually relies on system initialization scripts, as the settings are not preserved across reboots by setserial itself. With the advent of udev and more dynamic kernel module loading, its direct use for initial system setup has become less common, especially for USB-to-serial adapters which are managed differently. However, it still serves as a valuable diagnostic tool for traditional UART-based serial ports.
CAVEATS
Settings made with setserial are generally not persistent across system reboots; they must be re-applied via system initialization scripts (e.g., /etc/rc.local or distribution-specific configuration files). It primarily configures traditional UARTs and is less relevant for USB-to-serial converters or modern virtual serial ports which are managed dynamically by udev and sysfs. Root privileges are typically required to modify serial port settings.
IMPORTANT DEVICE CONFIGURATION PARAMETERS
When configuring a specific serial device using setserial <device> <parameters>, various settings can be specified after the device path (e.g., /dev/ttyS0). Common and important examples include:
port <address>: Sets the I/O base address for the serial port (e.g., 0x3f8 for COM1).
irq <number>: Assigns the Interrupt Request (IRQ) line (e.g., 4 for COM1).
uart <type>: Specifies the UART chip type present (e.g., 16550A, 16450, or none). This helps the kernel driver optimize.
baud_base <rate>: Sets the base baud rate divisor for the port, from which actual communication baud rates are derived (e.g., 115200).
Other flags can control behavior like auto_irq (automatically detect IRQ), skip_test (skip IRQ/port testing during boot), low_latency (optimize for low-latency communication), and various flow control or closing wait settings.
MODERN ALTERNATIVES AND PERSISTENCE
In modern Linux systems, especially for USB-to-serial adapters, serial ports are typically managed by udev rules and kernel modules which automatically detect and configure devices. For persistent configuration of traditional serial ports, commands are often placed in system initialization scripts like /etc/rc.local, or in specific configuration files provided by the distribution (e.g., /etc/default/setserial or a systemd service). Direct, ad-hoc manipulation with setserial is now more common for diagnosing issues with legacy hardware rather than initial setup or permanent configuration.
HISTORY
setserial has been a part of Linux since its early days, providing essential functionality for configuring hardware serial ports, particularly for modem and terminal connectivity on physical COM ports. Its prominence began to decline significantly with the introduction of the 2.6 series kernel and the udev daemon, which revolutionized dynamic device management and device file creation. While still included in most distributions for backward compatibility and specific diagnostic purposes, its role in initial system configuration has largely been superseded by automated device detection and configuration frameworks.