Adding / Removing Shell scripts (Ubuntu 8.10)
Posted by stringofthoughts on April 16, 2009
I’ve been trying to add a auto mount script to mount all my window drives at startup. After searching for a while and testing few test scripts I finally found out how to add scripts at startup and how to remove scripts.
Adding a script
First of all write a script, say test.sh and put it in the directory /etc/init.d . Next we need to make it executable so.
$ sudo chmod +x test.sh
You can check if the script is working by issuing
$ sudo ./test.sh
Assuming the script is working as expected, to make the script run at startup / reboot.
$ sudo update-rc.d -f test.sh start 99 2 3 4 5 . // Run at startup
$ sudo update-rc.d -f test.sh start 1 0 6 . // Run at reboot
Just a reminder there is dot (.) at the end of command. Don’t forget that . Now you are done adding a script to run at startup.
Removing a script.
Just a reminder for new users, don’t just go to /etc/init.d and delete the script file that wouldn’t help and may cause you trouble. We need a nice little app called rcconf ( Debian runlevel configurtion tool)
$ sudo apt-get install rcconf
then run rcconf (only root can run rcconf)
$ sudo rcconf
The inteface is very simple. It lists the scripts so all you need to do is find out where is your script and toggle “*” using space bar and then select OK. That’s all. The script is now removed but still present in the directory /etc/init.d but you can safely delete it now.