System init definitions (old)

The System V init daemon starts and stops processes when the runlevel is being changed.

The Upstart init daemon is a state machine. It keeps track of the state of jobs and, as events are triggered, tracks jobs as they change states. When init tracks a job from one state to another, it may execute the job's cmds or terminate the job.

An event is a change in state that init can be informed of. Almost any change in state (either internal or external to the system) can trigger an event. For example, the boot loader triggers the startup event, the system entering runlevel 2 triggers the runlevel 2 event, and a filesystem being mounted triggers the path-mounted event. You can also trigger an event manually by using the initctl emit cmd.

A job is a series of instructions that init reads. The instructions typically include a program (binary file or shell script) and the name of an event. The Upstart init daemon runs the program when the event is triggered. A job can be started and stopped manually using initctl. Jobs are divided into tasks and services.

The /etc/event.d dir holds job definition files (files defining the jobs that the Upstart init daemon runs). Initially this dir is populated by Upstart software packages. With new Ubuntu releases, files in this dir will replace the files in /etc/rc?.d and /etc/init.d dir.

A task is a job that performs its work and returns to a waiting state when it is done.

A service is a job that does not normally terminate by itself. For example, the logd daemon and the gettys are implemented as services. The init daemon monitors each service, restarting the service if it fails and killing the service when it is stopped manually or by an event.