How do I check and configure serial ports under Linux for various purposes such as modem, connecting null modems or connect a dumb terminal?
Linux offers various tools. Linux uses ttySx for a serial port device name. For example, COM1 (DOS/Windows name) is ttyS0, COM2 is ttyS1 and so on.
Task: Display Detected System's Serial Support
Simple run dmesg command
$ dmesg | grep tty
Output:
[ 37.531286] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 37.531841] 00:0b: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 37.532138] 0000:04:00.3: ttyS1 at I/O 0x1020 (irq = 18) is a 16550A
setserial command
setserial is a program designed to set and/or report the configuration information associated with a serial port. This information includes what I/O port and IRQ a particular serial port is using, and whether or not the break key should be interpreted as the Secure Attention Key, and so on. Just type the following command:
$ setserial -g /dev/ttyS[0123]
Output:
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4 /dev/ttyS1, UART: 16550A, Port: 0x1020, IRQ: 18 /dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4 /dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
setserial with -g option help to find out what physical serial ports your Linux box has.
Linux serial console programs
Once serial ports identified you can configure Linux box using various utilities:
- minicom- The best friendly serial communication program for controlling modems and connecting to dump devices
- wvidial or other GUI dial up networking program - a PPP dialer with built-in intelligence.
- getty / agetty - agetty opens a tty port, prompts for a login name and invokes the /bin/login command.
- grub / lilo configuration - To configure serial port as the system console
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 20 comments… read them below or add one }
I don’t know if this is the place, but I’m looking for information that is similar. I have 2 machines setup through a null modem. I want to read through the com port from one machine to the other. The sending machine is running Windows sending through COM1: and the receiving computer is Linux Red Hat. Any help on this would be appreciated.
another simple serial console program not mentioned is gtkterm.
I want to advise you that probably there is an error in the last sentence “seserial with -g option help to find out what physical serial ports your Linux box has.”; isn’t it setserial?
Bye
I have 4 standard serial ports defined, /dev/ttyS0-4, but I added a PCI-E 16 port serial adapter, and I have not found a way to connect anything to the upper 16 ports.
How do you create the virtual links? what options do you give setserial to define the new ports?
it dosn’t work :( I can’t connect to my ASA using debian.
Daemon is a program called getty used by UNIX/Linux systems. There are many different versions of getty. The first modem detected is /dev/ttys0 or /dev/ttys1. To create a link to the devices file so that you can view modem information. Type ln -s /dev/ttys1 /dev/modem.
It is essential to set the modem to AUTO ANSWER using getty.
download minicom from alioth.debian.org/projects/minicom.
create a modem config file by entering minicom -s from the root command line
select the options you want to configure using AT commands
connect to the modem by typing in minicom
Thanks very useful..save my time :)
Hi,everybody
I have a serial PCI card with two ports but neither of them is working, on Linux fedora 16. I have tried using “gtkterm” and “minicom” but unfortunately I can’t make a serial connection to my Cisco lab. Here is my output when I issue the command: “setserial -g /dev/ttyS[0123]“.
/dev/ttyS0, UART: 16550A, Port: 0xec00, IRQ: 16
/dev/ttyS1, UART: 16550A, Port: 0xe880, IRQ: 16
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
also I want to mention that when I try to connet throught the terminal it generates a message like so: ” Cannot open /dev/ttyS0: Permission denied”.
any help please.
abdel
Check the permissions on /dev/ttyS0… Likely problem is it’s owned by root, and is part of the uucp group. Add yourself to the uucp group, and all should be better. I’m curious to know if this is enough for you as I am having problems communicating with a serial port on Linux as well. I got past the permissions stuff, but it is still not working.
Thanks Tom,
I actually I tried but it’s does not work, still says “permission denied”. I would appreciate if you explain to me step by step the procedure how to do it, I’m knew to Linux.
Best Regards
Abdel
1) ls -la /dev/ttyS0 — This will report the permissions on the port. Typically, this will say crw-rw—- 1 root uucp. The “c” in the string indicates that it’s a “character device” the first “rw” indicates that the owner has read/write permission. The second “rw” means that the group has read/write permissions. The “—” indicates that the rest of the world has no permissions. After the “—-”, “root” indicates that the owner of the device is root, and that the group id is “uucp”. So, you either need to be root, or a member of the uucp group to have read/write access to the port.
2) To add yourself to the uucp group (to get read/write access), you need to edit the file /etc/group, and add your user name to the line that begins with “uucp:” User names are separated by commas, so add a comma, then your user name to the end of the line. You will need root permissions to edit this file.
3) log out, and log back in because group associations are made at login time, and are not queried on each request.
Thanks Tom,
here is my output from the group file I have added my username to it but does not work.
abdelinux:x:1000:uucp,adm,abdelinux,
I will just give up.Thanks a lot for your help I relay appreciate it.
Your entry in /etc/group is incorrect. If you read my previous post, I said to add your user id to the line that _begins_ with uucp. You added uucp to the group of users that can access your account. You want an entry in the /etc/group file that looks something like:
uucp:x:14:uucp,abdelinux
The critical element is that it’s the line that begins with uucp
Hi Tom,
It works. I just add my username to ” dialout ” and it worked fine. Iwould like to thank you for you time and support.
Best Regards
Abdel
hi,
I have connected the SIM300(gsm model) to my pc running ubuntu. I need a code to send a AT command to the GSM module and it should read and display the reply.
Please let me know steps.
I tried so many methods and codes, but no use…
Thank you
i need C code(program).
all my ttyS* shows unknown, earlier it was working fine, now it doesnt recognise
setserial -g /dev/ttyS*
/dev/ttyS0, UART: unknown, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
#cat /etc/redhat-release
CentOS Linux release 6.0 (Final)
#dmesg | grep tty
console [tty0] enabled
can u pls help me
tried spending time in google two days, still no success, tried connecting a brand new device too, still no success.
Sorry, but that second sentence is not necessarily true. I have a PC with two dual com port adapters. Windows sees them as COM1 -> COM4 (there is no built in COM port). Linux sees them as /dev/ttyS4->/dev/ttyS7.
/dev/ttyS0-/devttyS3 are apparently reserved, exist whether or not a physical port exists, and /dev/ttyS0 for certain is “special” in that it is used by the default terminal window:
dmesg | grep tty [ 0.000000] console [tty0] enabled [ 1.009457] 0000:02:00.0: ttyS4 at I/O 0xd030 (irq = 16) is a ST16650V2 [ 1.077312] 0000:02:00.1: ttyS5 at I/O 0xd020 (irq = 17) is a ST16650V2 [ 1.141309] 0000:02:00.2: ttyS6 at I/O 0xd010 (irq = 18) is a ST16650V2 [ 1.205307] 0000:02:00.3: ttyS7 at I/O 0xd000 (irq = 19) is a ST16650V2 setserial -g /dev/ttyS[012345657] /dev/ttyS0, UART: unknown, Port: 0x03f8, IRQ: 4 /dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3 /dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4 /dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3 /dev/ttyS4, UART: 16650V2, Port: 0xd030, IRQ: 16 /dev/ttyS5, UART: 16650V2, Port: 0xd020, IRQ: 17 /dev/ttyS6, UART: 16650V2, Port: 0xd010, IRQ: 18 /dev/ttyS7, UART: 16650V2, Port: 0xd000, IRQ: 19I think minicom still superior to other console utility.