(Just because I came across this several times during the last weeks being asked by Linux newbees. )
If you want to have a script, a command or a program run at autostart on Linux, put it into /etc/rc.local. On my Ubuntu or Mint systems this file has the following content:
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
If you add a line like echo “`date`: Hello, dude, I am just booting.” > /tmp/bootlog here, the next time your system starts you will find a timestamp followed by the nice greeting inside the file /tmp.bootlog:
Thu Dec 8 16:06:35 CET 2011: Hello, dude, I am just booting.
Mind that this only works on systems that (perhaps you’ll use locate rc.local) to check that) have the relevant init script /etc/init.d/rc.local on their hard drive. My Ubuntu/Mint systems have the test following test included:
if [ -x /etc/rc.local ]; then
[ “$VERBOSE” != no ] && log_begin_msg “Running local boot
[ “$VERBOSE” != no ] && log_end_msg $ES
Basically, this test makes sure that it is executed if it exists. If you have symbolic links like these:
then this script will be run always on the start of runlevels 2,3,4 and 5. You can change that behaviour with the command update-rc.d (a very good manpage is available).