How To Check and Use Serial Ports Under Linux

by on January 30, 2008 · 23 comments· LAST UPDATED January 28, 2010

in , ,

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

[   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]

/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:

  1. minicom- The best friendly serial communication program for controlling modems and connecting to dump devices
  2. wvidial or other GUI dial up networking program - a PPP dialer with built-in intelligence.
  3. getty / agetty - agetty opens a tty port, prompts for a login name and invokes the /bin/login command.
  4. grub / lilo configuration - To configure serial port as the system console
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 23 comments… read them below or add one }

1 Scott September 29, 2008 at 6:14 pm

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.


2 leszek September 30, 2008 at 4:34 pm

another simple serial console program not mentioned is gtkterm.


3 Alessandro January 28, 2010 at 8:38 am

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?



4 Mike Bushroe April 12, 2011 at 7:17 pm

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?


5 arek April 17, 2011 at 8:20 am

it dosn’t work :( I can’t connect to my ASA using debian.


6 Joe Knifer November 1, 2011 at 6:39 pm

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

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


7 AC November 10, 2011 at 12:28 pm

Thanks very my time :)


8 abdel January 19, 2012 at 1:41 pm

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.


9 Tom Schuneman January 23, 2012 at 10:29 pm

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.


10 abdel January 25, 2012 at 2:11 pm

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


11 Tom Schuneman January 25, 2012 at 4:36 pm

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.


12 abdel January 28, 2012 at 1:22 am

Thanks Tom,
here is my output from the group file I have added my username to it but does not work.


I will just give up.Thanks a lot for your help I relay appreciate it.


13 Tom Schuneman January 30, 2012 at 4:04 pm

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:


The critical element is that it’s the line that begins with uucp


14 abdel January 31, 2012 at 8:58 am

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


15 Mahesh April 14, 2012 at 1:35 pm

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


16 Mahesh April 14, 2012 at 1:37 pm

i need C code(program).


17 nicolethomson May 22, 2012 at 1:32 pm

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


18 nicolethomson May 25, 2012 at 1:31 am

tried spending time in google two days, still no success, tried connecting a brand new device too, still no success.


19 mickeyf July 4, 2012 at 6:01 pm

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: 19


20 Arash Jaberi September 21, 2012 at 11:39 am

I think minicom still superior to other console utility.


21 Kevin October 30, 2013 at 9:33 pm

Hi All tried all of the above and still get permission denied ???? HELP

kevin@Linux-Radio:~/bpq$ groups ${USER}
kevin : kevin adm dialout cdrom sudo dip plugdev lpadmin sambashare
kevin@Linux-Radio:~/bpq$ setserial -g /dev/ttyS[012345657
/dev/ttyS[012345657: No such file or directory
g7uxw@Linux-Radio:~/bpq$ setserial -g /dev/ttyS[012345657]
/dev/ttyS0: Permission denied
/dev/ttyS1: Permission denied
/dev/ttyS2: Permission denied
/dev/ttyS3: Permission denied
/dev/ttyS4: Permission denied
/dev/ttyS5: Permission denied
/dev/ttyS6: Permission denied
/dev/ttyS7: Permission denied


22 Baran June 25, 2014 at 4:58 pm

try this kevin

sudo setserial -g /dev/ttyS1


23 Amit July 31, 2014 at 5:19 am

Please help me
i am install minicom and use serial modem sim300 v7.03 but there is problem to type AT cmd on minicom console…….


Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: