Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 script at /etc/init/ttyS0.conf. I'm configuring a KVM guest for Serial Console access so even if the network interface is broken, I can still access it via the serial connection.

I can start the ttyS0 by running sudo start ttyS0 and it works just fine until I reboot. Upon rebooting the system, the ttyS0 isn't running anymore.

How can I get this script to to tun automatically at startup?


Here's what my script looks like:

# ttyS0 - getty
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

exec /sbin/getty -L 115200 ttyS0 xterm
share|improve this question
up vote 1 down vote accepted

From here

console none

start on (local-filesystems)
stop on [!12345]


exec start ttyS0
end script

Should work i suspect. else, replace start tty0 with a script that starts what you want to start

share|improve this answer

There are several ways to do this.

If the script invokes a process you can use /etc/init.d.

Put the script into /etc/init.d, you will need then to change the permissions on the file using chmod a+x "script". Then run update-rc.d "script" defaults, which kicks everything into gear. The script should start on boot now.

Here are some other examples:

Example 1

Example 2

share|improve this answer

Ubuntu uses SYSV startup (same as Debian) based on runlevels.

You have to add the script to the runlevel you're currently using. For Ubuntu the runlevel used by the init process is 2 by default. Thus you have to add ttyS0.conf to rC2.d directory and stating you want to start it (not stopping). You can do so by adding a soft link to the script like this:

ln -s /etc/init/ttyS0.conf /etc/rc2.d/S99ttyS0.conf

The S99 prefix indicates "S" -> start the script and "99" order in which the script has to be launched (lower this number if other scripts needs to run after this one).

Then you need to stop it when rebooting (runlevel 6) or shutting down (runlevel 0):

ln -s /etc/init/ttyS0.conf /etc/rc0.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc6.d/S99ttyS0.conf

Prefix is similar except that "S" -> stop script (only for runlevels 0 and 6).

Hope this helps. More info here

share|improve this answer
actually, it uses upstart now, but old style init scripts ought to work – Journeyman Geek Aug 22 '11 at 11:28
Hi Journeyman, I read up upstart and it seems to be the right way to do this evn though my script is in sync with the upstart specs, it doesn't start when the system boots/restarts. Any ideas? Please have a look at my edit. I've added my script there. – Mridang Agarwalla Aug 22 '11 at 11:38

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.