Screen command provides different window types. The first parameter to the screen command defines which type of window is created. If a tty name (e.g. “/dev/ttyS0”) is specified as the first parameter to the screen command, the window is directly connected to this device. An optional parameter is allowed consisting of a comma-separated list of flags in the notation as follows.
Screen Command: Set Baud Rate
The syntax is:
screen /dev/ttySX baud_rate,cs8|cs7,ixon|-ixon,ixoff|-ixoff,istrip|-istrip
screen /dev/{console_port} 115200
Where,
- /dev/ttySX: Linux serial port (e.g., /dev/ttyS0 [COM1] )
- baud_rate: Usually 300, 1200, 9600 (default), 19200, or 115200. This affects transmission as well as receive speed.
- cs8 or cs7: Specify the transmission of eight (or seven) bits per byte.
- ixon or -ixon: Enables (or disables) software flow-control (CTRL-S/CTRL-Q) for sending data.
- ixoff or -ixoff: Enables (or disables) software flow-control for receiving data.
- istrip or -istrip: Clear (or keep) the eight bit in each received byte.
How to list serial ports under Linux
We use the dmesg command as follows:
$ dmesg | grep tty ## use grep command/egrep command as filter ##
$ sudo setserial -g /dev/ttyS[0123]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4 /dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3 /dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4 /dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
Installing screen
Before we can use screen to connect to the serial console install it as per your version of Linux/Unix system:
## Debian/Ubuntu use apt command/apt-get command: ##
$ sudo apt install screen
## RHEL/CentOS/Oracle Linux users use the yum command ##
$ sudo yum install screen
## Fedora Linux users try the dnf command ##
$ sudo dnf install screen
Setting up baud rate with screen command on Linux or Unix
In this example, I’m connecting to my Soekris based embedded router using /dev/ttyS0 with 19200 baud rate and cs8:
$ screen /dev/ttyS0 19200,cs8
Sample outputs:
Using screen to connect to the serial console with 300 baud rate
We set a differnet baud rate as follows:
$ creen /dev/ttyS1 300
How Do I See My Serial Port Status and Info?
Simply type CTRL + A + i
How Do I Exit From the Screen Session?
To close the screen session after you finish the router / switch configuration, press CTRL + A + k. To kill all screen session press CTRL + A + \. See our quick screen command tutorial for more information.
Conclusion
You learned how to use screen command to set up baud rate and other settings for serial communication with routers and other devices. See
- See how to install and use minicom which is a communication program that runs under most unices.
- How to setup a serial console under Debian, FreeBSD or OpenBSD.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Great quick article, to the point. Used it as a reference. Thank you.
Glad you found it useful.