In computing, a daemon is a program that runs as a background process, rather than being under the direct control of an interactive user. Customary convention is to name a daemon process with the letter d as a suffix to indicate that it's a daemon. For example, syslogd is a daemon that implements system logging facility, and sshd is a daemon that serves incoming SSH connections.
Even though the concept can apply to many computing systems, the term daemon is used almost exclusively in the context of Unix-based systems. In other contexts, different terms are used for the same concept.
In a Unix-based system, the parent process of a daemon is often, but not always, the init process. A daemon is usually created either by a process forking a child process and then immediately exiting, thus causing init to adopt the child process, or by the init process directly launching the daemon. In addition, a daemon launched by forking and exiting typically must perform other operations, such as dissociating the process from any controlling terminal (tty). Such procedures are often implemented in various convenience routines such as daemon(3) in Unix.
Systems often start daemons at boot time that will respond to network requests, hardware activity, or other programs by performing some task. Daemons such as cron 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 at MIT's Project MAC. According to Fernando J. Corbató, who worked on Project MAC around 1963, his team was the first to use the term daemon, inspired by Maxwell's demon, an imaginary agent in physics and thermodynamics 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 a daemon as a supernatural being working in the background.
In the general sense, daemon is an older form of the word "demon", from the Greek δαίμων. In the Unix System Administration Handbook Evi Nemeth states the following about daemons:[3]
Many people equate the word "daemon" with the word "demon", implying some kind of satanic connection between UNIX and the underworld. 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. The ancient 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 include service (used in Windows, from Windows NT onwards, and later also in Linux), started task (IBM z/OS),[4] and ghost job (XDS UTS). Sometimes the more general term server or server process is used, particularly for daemons that operate as part of client-server systems.[5] A daemon that connects to a computer network is a network service.
After the term was adopted for computer use, it was rationalized as a backronym for disk and execution monitor.[6][1]
In a strictly technical sense, a Unix-like system process is a daemon when its parent process terminates and the daemon is assigned the init process (process number 1) as its parent process and has no controlling terminal. However, more generally, a daemon may be any background process, whether a child of the init process or not.
On a Unix-like system, the common method for a process to become a daemon, when the process is started from the command line or from a startup script such as an init script or a SystemStarter script, involves:
setsid()
open()
creat()
If the process is started by a super-server daemon, such as inetd, launchd, or systemd, the super-server daemon will perform those functions for the process,[7][8][9] except for old-style daemons not converted to run under systemd and specified as Type=forking[9] and "multi-threaded" datagram servers under inetd.[7]
In MS-DOS, daemon-like functionality was implemented as a terminate-and-stay-resident program (TSR).
In Windows, a Windows 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. In Windows 2000 and later versions, a Windows service is configured and controlled via various interfaces including the Control Panel, the Service Control Manager sc command, the net start and net stop commands, PowerShell, or a custom program.
sc
net start
net stop
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.
In classic Mac OS, optional features and services were provided by system extensions and control panels – files loaded at startup time that patched the operating system. Later versions of classic Mac OS augmented these with faceless background applications: regular applications that ran in the background. To the user, these were still described as regular system extensions.
The more modern macOS, which is Unix-based, uses daemons but uses the term "services" to designate software that performs functions selected from the Services menu, rather than using that term for daemons, as Windows does.
inetd(8)
launchd.plist(5)