Manage Services in Debian

In Red Hat Enterprise Linux (RHEL) and similar distributions, we get the chkconfig and service commands to manage services. In Debian, we also have similar but not the same commands.

Control Services at Boot

When the computer boots, the init process is the parent process that starts all other processes and services. All services started at boot are put in /etc/init.d/ and init just reads these scripts and starts the services. To control which services should run in which runlevels, the /etc/rcn.d/ (where n stands for run level number) directory contains symlinks to the scripts in /etc/init.d/ directory. For example, if a service needs to be started in runlevel 4, /etc/rc4.d/ would have a symlink to its corresponding script in /etc/init.d/ directory. For more details, check out Debian Policy Manual –  System run levels and init.d scripts.

To manage which services should run in which run level, use the update-rc.d command. This is equivalent to the chkconfig command in RHEL. Some example of using the command are as below (Debian notes):

Insert scripts into /etc/rcn.d/ directory for a particular service, script for which must exist in /etc/init.d/: update-rc.d service defaults
Disable service at boot time: update-rc.d service stop runlevelnumber
Disable service at boot but is less permanent, as upgrading package or distribution reverses this command: update-rc.d -f service remove
Enable service in all run levels: update-rc.d service start 20 2 3 4 5 . stop 20 0 1 6

If you are looking to use the chkconfig command because it seems easier, then you need to install sysv-rc-conf package.

sudo aptitude install sysv-rc-conf

However, instead of chkconfig, you will use sysv-rc-conf command.

Control Services While System is Running

But how do you start and stop a service without affecting whether it starts or not at boot time? In RHEL we have service command, and in Debian we have /etc/init.d/.

Start service: /etc/init.d/service start
Stop service: /etc/init.d/service stop
Restart service: /etc/init.d/service restart
Reload configuration: /etc/init.d/service reload
Force reload: /etc/init.d/service force-reload

Some great resources to check out are: Making scripts run at boot time with Debian; Remove unwanted startup files or services; Securing Debian manual – Appendix A – The hardening process step by step; Getting started with your Debian server;

2 Responses to Manage Services in Debian

  1. Mike says:

    aptitude install bum

  2. Pingback: Confluence: Indoor Positiong Platform Dev

%d bloggers like this: