remote-lab.net learn by doing

Startup scripts in Ubuntu and Debian based Linux distributions

Here are 2 simple steps which help you to run a script when your Ubuntu machine boots:

  1. Edit your script and add it in /etc/init.d/
  2. Run update-rc.d script which creates a link to your script on each of the runlevels  with a set priority.
root@virtual:/etc/init.d# update-rc.d vbox.sh defaults 85
update-rc.d: warning: /etc/init.d/vbox.sh missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts
 Adding system startup for /etc/init.d/vbox.sh ...
   /etc/rc0.d/K85vbox.sh -> ../init.d/vbox.sh
   /etc/rc1.d/K85vbox.sh -> ../init.d/vbox.sh
   /etc/rc6.d/K85vbox.sh -> ../init.d/vbox.sh
   /etc/rc2.d/S85vbox.sh -> ../init.d/vbox.sh
   /etc/rc3.d/S85vbox.sh -> ../init.d/vbox.sh
   /etc/rc4.d/S85vbox.sh -> ../init.d/vbox.sh
   /etc/rc5.d/S85vbox.sh -> ../init.d/vbox.sh