Differences between revisions 23 and 46 (spanning 23 versions)
Revision 23 as of 2011-07-03 18:22:16
Size: 3199
Comment: add daemon management info
Revision 46 as of 2017-08-19 10:27:16
Size: 5248
Editor: ?AndreasKlust
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English-~ ~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English - [[fr/Daemon|Français]] - [[it/Daemon|Italiano]]-~
Line 4: Line 4:
A [[WikiPedia:Daemon_(computing)|daemon]], or system service, is a background process usually started during the initial boot sequence by [[init]]. Daemons typically run independent of users, waiting for system events to occur and providing services in response. Some common daemons include: A [[WikiPedia:Daemon_(computing)|daemon]], or system service, is a background process usually started during the boot sequence. Daemons typically run independent of users, waiting for events to occur and providing services in response. Some common daemons include:
Line 10: Line 10:
## If your page gets really long, uncomment this Table of Contents
## <<TableOfContents(2)>>
<<TableOfContents>>
Line 13: Line 12:
== Managing daemons in Debian ==
Debian makes use of [[WikiPedia:Init#SysV-style|System V]]-style init scripts for daemon management. This allows daemons to operate conditionally, based on the current RunLevel of the computer. For example, a daemon can be configured to run only when the computer is in single-user mode (runlevel 1) or, more commonly, when in multi-user mode (runlevels 2-5). For more information, see [[init]] and [[RunLevel]].
Line 16: Line 13:
''Note: Many daemons provide essential services to a working Debian installation; others can pose unnecessary security risks when enabled carelessly. Caution should be used whenever managing daemons. When in doubt, refer to the documentation of the daemon itself.'' == Daemon management with systemd ==
Since [[DebianJessie]], [[systemd]] is used to manage daemons.
Line 18: Line 16:
=== Common tasks ===
Most system services accept a common set of options, which can be passed directly to the daemon script at the command line, for example:
=== Common daemon control ===
Daemons are controlled with the systemctl command:
Line 21: Line 19:
# /etc/init.d/ssh restart # systemctl <COMMAND> <NAME>
}}}
where NAME is the name of the service or daemon. The most common commands for controlling daemons are:
 * '''start''': starts a service immediately
 * '''stop''': stops a service immediately
 * '''restart''': restarts a service
 * '''reload''': asks a service to reload its configuration
 * '''status''': shows the current status of a service

For instance, the sshd daemon is restarted by
{{{
# systemctl restart ssh
}}}

=== Enable/disable daemons ===
The systemctl command is also used to enable or disable the start of a daemon during system boot:
{{{
# systemctl <COMMAND> <NAME>
}}}
where NAME is the name of the service or daemon. The most important commands to enable/disable daemons are:
 * '''enable''': enable service to be started during boot sequence
 * '''disable''': do not start service during boot sequence
 * '''is-enabled''': check if a service is already enabled

Note that the enable/disable commands only affect the system at the next boot. To change the system immediately, use the ''--now'' option. For instance:
{{{
# systemctl --now disable ssh
}}}
will prevent starting sshd at the next boot and stop the daemon immediately.


== Daemon management with sysvinit ==
Before [[DebianJessie]], [[WikiPedia:Init#SysV-style|System V]]-style init scripts were used for daemon management by default. This allows daemons to operate conditionally, based on the current RunLevel of the computer. For example, a daemon can be configured to run only when the computer is in single-user mode (runlevel 1) or, more commonly, when in multi-user mode (runlevels 2-5). For more information, see [[Init]] and [[RunLevel]].

The [[http://www.debian.org/doc/debian-policy/|Debian Policy Manual]] (sections [[http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit|9.3]] and [[http://www.debian.org/doc/debian-policy/ch-opersys.html#s9.4|9.4]]) is an excellent resource for better understanding daemon init scripts in Debian.

=== A brief introduction to Debian sysvinit init scripts ===
Daemon init scripts are stored in {{{/etc/init.d/}}} along with the system's other boot-time init scripts.

When a daemon is enabled or disabled, symbolic links targeting the respective init script are created or removed under the various {{{/etc/rc*.d/}}} directories, corresponding to the RunLevel(s) in which the daemon is to run.

Daemon init scripts are treated as configuration files by [[dpkg]]. This means they remain on the system after a package is uninstalled, unless the '{{{purge}}}' option is used.

=== Common daemon controls ===
Most daemon scripts accept a common set of options, which can be passed directly to the script at the command line, for example:
{{{
# service ssh restart
Line 24: Line 68:
A brief description of each option follows: A brief description of the most common options follows:
Line 31: Line 75:
Stopping and starting daemons in this manner is temporary and will not survive a reboot. Refer to the next section to enable/disable daemons on a more permanent basis. Starting and stopping daemons in this manner is temporary and will not survive a reboot. Refer to the next section to enable/disable daemons on a permanent basis.
Line 33: Line 77:
=== Add/remove daemons ===
The terms ''add'' and ''remove'' are a bit of a misnomer because we're not actually adding or removing the services from Debian, rather we're enabling or disabling them.
=== Enable/disable daemons ===
''Note: When in doubt, refer to the documentation of the daemon itself.''
Line 36: Line 80:
Several tools exist to manage system services, including DebianPkg:rcconf and DebianPkg:sys-v-conf. The default tool however is '''update-rc.d'''.
Line 38: Line 81:
==== Disabling services ====
To disable a service, run the following in a terminal as root:
To (re)enable/disable a daemon (using the default settings & runlevels) run the following command, where ''<daemon>'' corresponds to the name of the init script as listed in {{{/etc/init.d/}}}:
Line 41: Line 83:
# update-rc.d -f <servicename> remove # update-rc.d <daemon> enable|disable
Line 44: Line 86:
==== Enabling services ====
To (re)enable a service, using the default settings, run the following:
{{{
# update-rc.d <servicename> defaults
}}}
For more detail on what these commands do, refer to the [[DebianMan:8/update-rc.d|update-rc.d manpage]].
Line 50: Line 88:
For detailed information on what these commands do, refer to the '''update-rc.d''' manpage. For more information on Debian's way of managing and writing init scripts see [[LSBInitScripts/DependencyBasedBoot]] and [[LSBInitScripts]].

=== GUI utilities for daemon management ===
Several GUI tools exist to make daemon management even simpler; some popular examples available for Debian include: DebianPkg:rcconf and DebianPkg:sysv-rc-conf.
Line 53: Line 94:
 * [[init]]  * [[Init]]
Line 55: Line 96:
 * manpages: [[DebianMan:5/inittab|inittab]],[[DebianMan:8/init|init]],[[DebianMan:5/rcS|rcS]], [[DebianMan:8/update-rc.d|update-rc.d]], [[DebianMan:8/runlevel|runlevel]]  * manpages: [[DebianMan:5/inittab|inittab]], [[DebianMan:8/init|init]], [[DebianMan:5/rcS|rcS]], [[DebianMan:8/update-rc.d|update-rc.d]], [[DebianMan:8/runlevel|runlevel]], [[DebianMan:8/insserv|insserv]]
Line 58: Line 99:
## If this page belongs to an existing Category, add it below.
## CategorySomething | CategoryAnother
CategoryBootProcess

Translation(s): English - Français - Italiano


A daemon, or system service, is a background process usually started during the boot sequence. Daemons typically run independent of users, waiting for events to occur and providing services in response. Some common daemons include:

  • sshd - listens for and manages incoming ?SSH connections

  • acpid - listens for power management events and executes scripts based on them

  • apache - provides a local HTTP web server

Daemon management with systemd

Since DebianJessie, systemd is used to manage daemons.

Common daemon control

Daemons are controlled with the systemctl command:

# systemctl <COMMAND> <NAME>

where NAME is the name of the service or daemon. The most common commands for controlling daemons are:

  • start: starts a service immediately

  • stop: stops a service immediately

  • restart: restarts a service

  • reload: asks a service to reload its configuration

  • status: shows the current status of a service

For instance, the sshd daemon is restarted by

# systemctl restart ssh

Enable/disable daemons

The systemctl command is also used to enable or disable the start of a daemon during system boot:

# systemctl <COMMAND> <NAME>

where NAME is the name of the service or daemon. The most important commands to enable/disable daemons are:

  • enable: enable service to be started during boot sequence

  • disable: do not start service during boot sequence

  • is-enabled: check if a service is already enabled

Note that the enable/disable commands only affect the system at the next boot. To change the system immediately, use the --now option. For instance:

# systemctl --now disable ssh

will prevent starting sshd at the next boot and stop the daemon immediately.

Daemon management with sysvinit

Before DebianJessie, System V-style init scripts were used for daemon management by default. This allows daemons to operate conditionally, based on the current RunLevel of the computer. For example, a daemon can be configured to run only when the computer is in single-user mode (runlevel 1) or, more commonly, when in multi-user mode (runlevels 2-5). For more information, see Init and RunLevel.

The Debian Policy Manual (sections 9.3 and 9.4) is an excellent resource for better understanding daemon init scripts in Debian.

A brief introduction to Debian sysvinit init scripts

Daemon init scripts are stored in /etc/init.d/ along with the system's other boot-time init scripts.

When a daemon is enabled or disabled, symbolic links targeting the respective init script are created or removed under the various /etc/rc*.d/ directories, corresponding to the RunLevel(s) in which the daemon is to run.

Daemon init scripts are treated as configuration files by dpkg. This means they remain on the system after a package is uninstalled, unless the 'purge' option is used.

Common daemon controls

Most daemon scripts accept a common set of options, which can be passed directly to the script at the command line, for example:

# service ssh restart
Restarting OpenBSD Secure Shell server: sshd.

A brief description of the most common options follows:

  • start: start a service

  • stop: stop a service

  • restart: restart a service without reloading its job config file

  • reload: send a SIGHUP signal to running process

  • status: return the status of a service

Starting and stopping daemons in this manner is temporary and will not survive a reboot. Refer to the next section to enable/disable daemons on a permanent basis.

Enable/disable daemons

Note: When in doubt, refer to the documentation of the daemon itself.

To (re)enable/disable a daemon (using the default settings & runlevels) run the following command, where <daemon> corresponds to the name of the init script as listed in /etc/init.d/:

# update-rc.d <daemon> enable|disable

For more detail on what these commands do, refer to the update-rc.d manpage.

For more information on Debian's way of managing and writing init scripts see LSBInitScripts/DependencyBasedBoot and LSBInitScripts.

GUI utilities for daemon management

Several GUI tools exist to make daemon management even simpler; some popular examples available for Debian include: rcconf and sysv-rc-conf.

See also


CategoryBootProcess