If for whatever reason you stop using a certain service in your Ubuntu install and would like to disable automatic restarting for it upon system reboot, all it takes to do it is just one command line.
In most Unix distros, the startup and shutdown sequences of various system services are managed using a set of startup and shutdown scripts.
Startup scripts a’re usually located either in /etc/init.d or in /etc/rc.d/init.d/ directories (sometimes /etc/init.d is a symlink to /etc/rc.d/init.d). On top of these directories, they’re also a set of directories for each of your system runlevels: /etc/rc0.d, /etc/rc1.d, /etc/rc3.d, etc.
The reason scripts are organized this way is because in runlevel specific directories you only have symbolic links referring to the original script in /etc/init.d. Each of the scripts in this directory usually caters for a number of scenarios: starting a service up, stopping it, and, optionally, restarting it (which is the same as stopping/starting sequence in most cases).
As your Unix OS goes from one runlevel to another following a startup or shutdown, it looks for symlinks in /etc/rc*.d directories and uses them to ensure the services specified there are started or stopped accordingly.
PROMISE: One day, I will certainly spend more time talking about the Unix OS startup process itself, but for today I just want to concentrate on the scripts for a particular service.
So, for the FTP service, I have the /etc/init.d/proftpd startup/shutdown script plus the following set of symlinks referring to it:
If you look at any of them, you can see that they really are symlinks:
The procedure for disabling a service in Ubuntu is very simple: all you have to do is remove the symlinks from all the runlevel-specific directories, /etc/rc*.d, so that no links are pointing to the original /etc/init.d script for your service. That original script will be kept, so you can re-enable the startup/shutdown of the service whenever you feel like using it again.
This example below shows how a service called “proftpd” was disabled on my system:
You obviously don’t have to reboot your system just to stop your service though, so instead you can simply do this:
That’s all there is to it! Good luck with disabling the unused services!