Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a laptop which has only one serial port.

I went into:


directory, and I found:


How do I know which of those "ttyS" refers to my serial port?

share|improve this question
up vote 14 down vote accepted

I think it's this command:

dmesg | grep tty

Running that on my own Linux box (which only has 1 Serial port) produces a single ttyS0 output line. Try it on your own, you will see what I mean.

share|improve this answer
Does that mean that after running that command, if the response is ...console [tty0] enabled..., and no other, any device is connected to /dev/tty0 (sorry for the apparent silliness of the question)? – Hektor Feb 15 '15 at 23:49
The only problem is that dmesg output can be cleared - so if you run this too late, you're out of luck. Looking at /proc/tty/driver/serial seems the more robust answer and then check for rx interrupts increasing in count as you write data to that port – Neil McGill Aug 21 '15 at 15:49
Sorry, what do I have to do if I don't see any output? – user3019105 Jun 22 at 16:17

If you need to do this programmatically reading the output from dmesg can be troublesome, instead the folder /dev/serial/by-id has sym links that are named after identifiable data of your device and point to the specific /dev/tty* they are connected to.

I'm not sure if this is some special udev rule that is distribution specific, but it works well in Ubuntu, let me know if it works.

share|improve this answer

ttyS0 through 3 correspond to COM1 through 4, respectively. They usually have the same hardware resources and are not always detectable, so they always exist.

share|improve this answer
thanks for the answer. So say I want to tell Linux that I want ttyS0 to map to my serial port hardware, what do I need to do? – sivabudh Apr 14 '10 at 21:18
You would use setserial to map the resources ttyS0 uses to that of your serial port. This isn't normally required though, since anything beyond COM4 usually has enough auxiliary hardware to allow Linux to detect it and add a serial device as appropriate. – Ignacio Vazquez-Abrams Apr 14 '10 at 21:26

See which UARTs where detected in /proc/tty/driver/serial. A line with uart:unknown means: nothing detected (and likely not existent).

# cat /proc/tty/driver/serial 
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0
1: uart:16550A port:000002F8 irq:3 tx:111780 rx:1321 RTS|DTR|DSR
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3

If something is connected and driving the lines CTS, DSR or CD (these are input lines) you can even be pretty sure that there actually is something... Same is true for the rx-byte-count.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .