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.
Startup and shutdown scripts in Unix
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:
/etc/rc0.d/K20proftpd -> ../init.d/proftpd /etc/rc1.d/K20proftpd -> ../init.d/proftpd /etc/rc6.d/K20proftpd -> ../init.d/proftpd /etc/rc2.d/S20proftpd -> ../init.d/proftpd /etc/rc3.d/S20proftpd -> ../init.d/proftpd /etc/rc4.d/S20proftpd -> ../init.d/proftpd /etc/rc5.d/S20proftpd -> ../init.d/proftpd
If you look at any of them, you can see that they really are symlinks:
ubuntu# ls -l /etc/rc3.d/S20proftpd lrwxrwxrwx 1 root root 17 Jan 13 03:39 /etc/rc3.d/S20proftpd -> ../init.d/proftpd
Disabling startup of a service in Ubuntu
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:
ubuntu# update-rc.d -f proftpd remove Removing any system startup links for /etc/init.d/proftpd ... /etc/rc0.d/K50proftpd /etc/rc1.d/K50proftpd /etc/rc2.d/S50proftpd /etc/rc3.d/S50proftpd /etc/rc4.d/S50proftpd /etc/rc5.d/S50proftpd /etc/rc6.d/K50proftpd
You obviously don't have to reboot your system just to stop your service though, so instead you can simply do this:
ubuntu# /etc/init.d/proftpd stop * Stopping ftp server proftpd
That's all there is to it! Good luck with disabling the unused services!
- runlevel command in Unix
- uptime command
- How to find what symlink points to
- Symlinks (symbolic links) in Unix