Installing and removing services using rc.d

When installing stuff on your *nix box, you may want to have them automatically run upon startup, somewhat like a service. For that, you have the rc.d system that works with init based on your runlevel, and the Upstart system.

A basic way to understand the init/rc.d system is that the /etc/init.d/ scripts do the managing of the “services” that you want, and the rc.d scripts run the relevant init.d scripts based on the runlevel you’re booting into.

$ runlevel
N 2

The output of the runlevel command will let you know which runlevel you are in (2 in this case). For that, we assume that the rc2.d scripts are run.

Here’s an excerpt of the listing of the files in /etc/rc2.d/. You will see that there are links named starting with K, and others starting with S. The K ones are simply disabled (they don’t run when you enter that runlevel), and the S ones are enabled.

So…we assume that the relevant /etc/init.d/ script has been written/installed already, and here’s how you remove all links for a given service (pppd-dns in these examples).