Linux – the difference between “init” and “service manager”

initlinuxservicessystemdsysvinit

From When the operating system shuts down, how does a service manager know that it should sends SIGTERM and SIGKILL to its services?

systemd IS BOTH the init and service manager

What is the difference between "init" and "service manager"?

I guess they are the same thing?

What is some example which is "the init" but not "service manager"? Vice versa?

Thanks.

Best Answer

init is (usually) the first process started by the system. It has a couple of special responsibilities, including (but not limited to:

  • Starting whatever other userspace processes are necessary to finish the boot up process.
  • Handling the final shutdown of the system (init is what ultimately tells the kernel to power off or reboot once everything in userspace is shut down).
  • Adopting orphaned processes (processes which no longer have a running parent process) and cleaning up after them.

A service manager, on the other hand, is solely responsible for ensuring a given set of services are running, and optionally that they keep running. The exact approach to this can vary from rudimentary scripts that just track dependencies among services, to complex systems that automatically manage dependencies.

The original SVR4 init implementation (which is the basis for both the classic systemv-init packages on most Linux distributions, the Busybox init applet, and the BSD and Solaris init programs) actually included rudimentary service management. It let you define programs which it would automatically start at boot, and restart if they exited. As a result of this, it's actually pretty hard to find an init implementation on a UNIX-like system that isn't also a rudimentary service manager, and this baseline level of service management is largely implied to be part of the init process's job.

On the other hand, you can easily have a service manager that isn't an init implementation. The classic BSD rc.d scripts are an example of a really simple service manager (they handle starting and stopping services, and provide rudimentary dependency management), and they formed the basis of the concept of /etc/init.d on Linux. A more complex example is monit, which adds state tracking, automatic restart capabilities, alerting, and some system monitoring support to the basic functionality.