Server Fault is a question and answer site for system and network administrators. 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 server running Debian Linux which has a built in serial port which is coming up as ttyS0. I have a plug in PCI card with two serial ports that are being registered with Linux as ttyS2 and ttyS3.

Unfortunately I am trying to run some software which assumes that ttyS0 and ttyS1 are available. Is it possible to remap the serial port device names (using a udev rule?) such that ttyS0 remains as it is and ttyS2 becomes ttyS1?

share|improve this question
Is this open source? If it is can you link to it, might be easy to fix the software. – Kyle Brandt Apr 30 '10 at 13:27
It's a fragile piece of proprietary test software unfortunately. The long term plan is to fix it so that it will work on any machine configuration. – davefiddes Apr 30 '10 at 14:08
up vote 2 down vote accepted

You can use udev for this. Create a file /etc/udev/rules.d/90-rename-serial-ports.rule containing

ACTION=="add" KERNEL=="ttyS2" NAME="ttyS1"

should do it (not tested). Note the difference between "==" and "=".

share|improve this answer
This seems to work like a dream. Thanks! – davefiddes May 2 '10 at 17:47

How about a plain mv /dev/ttyS2 /dev/ttyS1? After all most devices are just a file located under /dev.

LE: You need to do the renaming every time you boot.

share|improve this answer

You shouldn't be fiddling with the names like this. Use setserial to unmap ttyS2 and to map ttyS1 to its resources. And then you should find whoever wrote that code and introduce them to the back of your hand. They really ought to know better by now.

share|improve this answer
Can't seem to see how to do this with setserial. Even if I could get it to work it wouldn't work with other serial devices like USB serial dongles which limits its utility. Also, bad software is worryingly common, getting angry about it doesn't help. I just try to stop it happening on my watch. – davefiddes May 2 '10 at 17:49

try this:

sudo ln -s /dev/ttys2 /dev/ttys1

It links ttys1 to the real ttys2.

Tested to work on applications such as minicom with a USB-to-serial adapter (/dev/ttyUSB0) on Ubuntu Lucid.

It does not survive reboots, unless you add it to a script (eg: /etc/rc.local on most Linux distros)

share|improve this answer
Actually, /dev is dynamically created on boot, so that won't survive a reboot. – fahadsadah Apr 30 '10 at 15:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.