
Incomputing, adaemon is aprogram that runs as abackground process, rather than being under the direct control of an interactive user. Customary convention is to name a daemon process with the letterd as a suffix to indicate that it's a daemon. For example,syslogd is a daemon that implements system logging facility, andsshd is a daemon that serves incomingSSH connections.
Even though the concept can apply to many computing systems, the termdaemon is used almost exclusively in the context ofUnix-based systems. In other contexts, different terms are used for the same concept.
Systems often start daemons atboot time that will respond to network requests, hardware activity, or other programs by performing some task. Daemons such ascron may also perform defined tasks at scheduled times.
In the context of computing, the word is generally pronounced either as/ˈdiːmən/DEE-mən or/ˈdeɪmən/DAY-mən.[1]
The term was coined by the programmers atMIT's Project MAC. According toFernando J. Corbató, who worked onProject MAC around 1963, his team was the first to use the term daemon, inspired byMaxwell's demon, an imaginary agent in physics andthermodynamics that helped to sort molecules, stating, "We fancifully began to use the word daemon to describe background processes that worked tirelessly to perform system chores".[2]Unix systems inherited this terminology. Maxwell's demon is consistent with Greek mythology's interpretation of adaemon as a supernatural being working in the background.
In the general sense, daemon is an older form of the word "demon", from theGreek δαίμων. In theUnix System Administration HandbookEvi Nemeth states the following about daemons:[3]
Many people equate the word "daemon" with the word "demon", implying some kind ofsatanic connection between UNIX and theunderworld. This is an egregious misunderstanding. "Daemon" is actually a much older form of "demon"; daemons have no particular bias towards good or evil, but rather serve to help define a person's character or personality. Theancient Greeks' concept of a "personal daemon" was similar to the modern concept of a "guardian angel"—eudaemonia is the state of being helped or protected by a kindly spirit. As a rule, UNIX systems seem to be infested with both daemons and demons.
Alternative terms includeservice (used in Windows, from Windows NT onwards, and later also in Linux),started task (IBMz/OS),[4] andghost job (XDSUTS). Sometimes the more general termserver orserver process is used, particularly for daemons that operate as part ofclient-server systems.[5] A daemon that connects to a computer network is anetwork service.
After the term was adopted for computer use, it was incorrectly[1] rationalized as abackronym fordiskandexecutionmonitor.[6][7][8]
In aUnix-like system, theparent process of a daemon is often, but not always, theinit process. A daemon is usually created either by the init process directly launching the daemon, by the daemon being run by an initialization script run by init, or by the daemon being launched by asuper-server launched by init.
The init process inResearch Unix andBSD starts daemons from an initialization script. A daemon started as a command in an initialization script must eitherfork a child process and then immediately exit, or must be run as a background process using&, so that the shell running the initialization script can continue after starting the daemon. In the former case, the daemon process run from the shell exits, thus causing init to adopt the child process that runs as the daemon; in the latter case, when the shell running the initialization script exits, the child daemon process is adopted by init.[9]
The versions of init inSystem III and inSystem V can run arbitrary commands and can be configured to run them once or to restart them when they terminate.[10][11][12][13] The former mechanism can be used to run initialization scripts; daemons started from those scripts behave the same as in Research Unix and BSD. The latter mechanism can be used to run daemons directly from init.
A daemon can also be launched from a user's command line. However, daemons launched in that fashion typically must perform other operations, such as dissociating the process from any controllingterminal (tty). Such procedures are often implemented in various convenience routines such asdaemon(3). A daemon launched by an initialization script need not do these steps, but doing so allows the daemon to be restarted by a user if it exits;[14] init itself would not restart them.[15] Operations such a daemon must do include:
setsid():open(),creat(), and other operating system calls to provide their own permission masks and not to depend on the umask of the caller.If the process is started by asuper-server daemon, such asinetd,launchd, orsystemd, the super-server daemon will perform those functions for the process,[16][17][18] except for old-style daemons not converted to run undersystemd and specified asType=forking[18] and "multi-threaded" datagram servers underinetd.[16]
InMS-DOS, daemon-like functionality was implemented as aterminate-and-stay-resident program (TSR).
InWindows, aWindows service provides the functionality of a daemon. It runs as a process, usually does not interact with the user (i.e. via monitor, keyboard, or mouse) and may be launched by the operating system at boot time. InWindows 2000 and later versions, a Windows service is configured and controlled via various interfaces including theControl Panel, theService Control Managersc command, thenet start andnet stop commands,PowerShell, or a custom program.
However, any Windows application can perform the role of a daemon, not just a service, and some Windows daemons have the option of running as a normal process.
Inclassic Mac OS, optional features and services were provided bysystem extensions andcontrol panels – files loaded at startup time that patched the operating system. Later versions of classic Mac OS augmented these withfaceless background applications: regular applications that ran in the background. To the user, these were still described as regular system extensions.
The more modernmacOS, which isUnix-based, uses daemons but uses the term "services" to designate software that performs functions selected from theServices menu, rather than using that term for daemons, as Windows does.
inetd(8) – FreeBSD System Manager'sManuallaunchd.plist(5) – Darwin andmacOS File FormatsManual