To execute a script at startup of Ubuntu

  • Edit /etc/rc.local and add your commands.
  • The script must always end with an un exit 0


To execute a script upon rebooting Ubuntu

  • Put your script in /etc/rc0.d
  • and make it executable (sudo chmod +x myscript)
  • Note that : The scripts in this directory are executed in alphabetical order.

The name of your script must begin with K99 to run at the right time.

To execute a script at shutdown

  • Put your script in /etc/rc6.d
  • and make it executable (sudo chmod +x myscript)
  • Note that: The scripts in this directory are executed in alphabetical order.

The name of your script must begin with K99 to run at the right time.

Original FAQ by Sebsauvage