If you ever want to switch to another runlevel while from within your current session, use the telinit command, followed by the number of the level you want to switch to. It's a good idea to try runlevel 3, for example, as with most distributions this will give you a good idea of the potential speed and memory improvements you can expect after you've gone to the trouble of pruning the services from your system you don't require. That means that you can't assume that our instructions for removing services from one runlevel are necessarily going to apply to your chosen distribution.
But before we can get stuck into editing which services we can safely remove, we need to make sure we can get back the default working configuration.
Fortunately, chckconfig can also be used to save the current configuration of services as well as checking those running and their runlevels. Just type chkconfig -A >services.save. This will pipe the output from the chkconfig command into a file called services.save, and if you look at this file in a text editor you'll see that it contains exactly the same output as the standard command.
This makes it a great solution if you can't remember exactly what services were running when you started tinkering with your system, because you can just load up the file and take a look. And as you might expect, you can use chkconfig to start and stop services, as well as changing the runlevels they're associated with.
The command chkconfig sshd off would stop the SSH server daemon, for example, while typing chkconfig sshd --level 23 off would ensure that SSH wouldn't be running when the system boots into levels three and four.
These changes are only made after a system reboot – even if you're just turning a service off. But the best thing about chkconfig is that when you've successfully managed to mess up your services installation, you can pipe the contents of that file back into chkconfig to restore the same services configuration out of the desolate wastes of a broken installation. You just need to type chkconfig -s
While chkconfig is a clear and quick way to view your daemons and save their configuration state, we wouldn't recommend its use for enabling and disabling them. There are graphical tools that are much better suited to the task. Ubuntu even includes a basic services editing window that can be opened from the System > Administration menu. But we'd recommend a tool called the Boot- Up Manager (it really is called 'bum' for short).
There are Ubuntu packages, and it's what Yast uses on OpenSUSE for enabling and disabling services. Just look for System Services in the Services section. In Export mode, the Boot-Up Manager lists all the possible daemons on your system, including those that aren't currently running, and enables you to select when each daemon runs and at what runlevel.
This leaves us prepared for the next step – finding out what the various services do, and which are safe to remove. As we've discussed, the number and type of services running are dependent on the distribution you're using. Some have more while some have fewer (Ubuntu), but we'll cover the most likely candidates for removal on most Linux distributions. You should try to disable one at a time, and make sure there aren't any ill effects from the change.
Cron, Anacron and atd
Likelihood that you'll miss it: 3/5
If you've ever used Cron to schedule the execution of a particular task at a specific time, you'll know exactly what the Cron daemon is responsible for. It patiently waits in the background for the correct date and time, before dutifully executing the command held in its configuration files. You can check exactly what Cron is getting up to by looking at the contents of /etc/crontab, and if you're happy to exclude those tasks from your system, you can safely disable Cron. A close cousin to Cron is called Anacron. This can be found running on Ubuntu, but not on OpenSUSE 11. The difference between Cron and Anacron is that Anacron ensures tasks are run even when the system isn't running. It will make sure a backup scheduled for the night before will be run when the machine is turned on. For this reason, Anacron is more likely to be used for system tasks. In a similar vein, you'll find the atd daemon, which controls the scheduling of tasks executed with the at command. This would normally be a non-recurring command that needs to be run at a specific time.