I have a machine (Debian/Ubuntu/CentOS mostly) that works like a kiosk, and there a few devices connected to it, using serial and USB ports. The software of these devices should know the port numbers, meaning device A is connected to /dev/ttyUSB0, device B to /dev/ttyUSB1, device C to /dev/ttyS0 and so on. Can I be certain that after a restart or kernel update, etc., these port numbers won't change, or should I have some other method to determine what's where?

  • You should use the /dev/serial/by-id/* or /dev/serial/by-path/* links instead of /dev/ttyUSB*. Or create your own link based on the device's attributes via an udev rule. See eg. this but there are lot of other answers and tutorials.
    – user313992
    Commented Feb 24, 2020 at 11:17
  • @mosvy Can I expect that /dev/serial/by-id/* would be accessible by all/most Linux distributions? Commented Feb 25, 2020 at 14:17
  • Almost. Some Linux systems like OpenWRT or Android don't have it. But all the "generic" distros (including Raspbian, etc) do.
    – user313992
    Commented Feb 25, 2020 at 17:16

1 Answer 1


You need to write a udev rule to assign consistent names based on which USB port the USB serial port adapter is plugged in to or the adapter's serial number.

I'm on my phone at the moment but I'll update the answer when I get back to my laptop and can add an example.


You must log in to answer this question.

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