Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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've got instruments hooked up to /dev/ttyS1 through ttyS9 on a machine running Debian Wheezy. The various instruments communicate at various speeds.

Is there a better way to set the baud rates than to have a bunch of lines like

stty -F /dev/ttyS1 19200 raw -echo
stty -F /dev/ttyS2 4800  raw -echo

in rc.local?

share|improve this question
The kernel drivers might understand some kernel command line parameters, which you could use by default. Depends on the hardware (read driver), I guess. – peterph Sep 19 '13 at 20:01
@peterph yeah, but /etc/rc.local seems way more elegant than to screw with the kernel command line. I agree with slm, /etc/rc.local is fine. – Martin von Wittich Sep 19 '13 at 20:54
up vote 4 down vote accepted

Not to my knowledge.

The /etc/rc.local file is the best location for creating customization that are specific to the box. It was specifically created for these types of custom changes and is the first place that most system administrators are conditioned to look when dealing with Unix/Linux boxes.

share|improve this answer
One might also create a separate script for that, that will be sourced/executed from within /etc/rc.local – peterph Sep 19 '13 at 21:41
@peterph - excellent point, yes if it's more elaborate, you might want to source a script with the contents of these commands in them instead. – slm Sep 19 '13 at 21:54

Install the setserial package. It can save serial port settings and restore them at boot time.

Alternatively, run a program when the port is detected via an udev rule. Put something like this (untested) in /etc/udev/rules.d/zzz_serial.rules:

KERNEL=="ttyS1", RUN+="/bin/stty -F /dev/ttyS1 19200 raw -echo"
share|improve this answer
When using RUN commands, you need to specify the full path, in this case /bin/stty. Otherwise you'll end up with : failed to execute '/lib/udev/stty' No such file or directory. – BorisHajduk Jul 8 '15 at 20:13

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.