Saturday, August 7, 2010

An rc.local equivalent for Debian/Ubuntu

An rc.local equivalent for Debian/Ubuntu


In many distributions you can add commands to run certain programs at the end of the boot process after all system services have been started. For this purpose various distribution uses various methods. For example in Redhat based distributions we can add our own scripts or programs into the /etc/rc.d/rc.local file, however there is no such file in a Debian based system. Here is the way to accomplish the same thing the debian way:

Creatting /etc/init.d/local

sudo vi /etc/init.d/local

This file is a shell script and it should start with:

#!/bin/sh

Making the file executable

Make this file executable with:

 sudo chmod +x /etc/init.d/local

link the new local file with Init

We are going to use this script a System V init script using:

sudo update-rc.d local defaults 80

An Example

Now you can call your scripts or pograms using this file. For example, to mount a NFS directry at boot time add the following line to /etc/init.d/rc.local

mount server.fossedu.org:/data /data

No comments: