What Is a Daemon?

March 20, 2024

A daemon is a computer program that runs in the background instead of being under the userโ€™s direct control. It performs tasks from the moment the operating system boots until the computer is turned off. These tasks include handling network requests, managing hardware devices, job scheduling, and providing services such as web serving, email delivery, or database management.

Daemons are widely used in UNIX and UNIX-like systems, where they have an integral role in maintaining functionality, managing resources, performing tasks, and offering a variety of system-critical services. Operating systems that donโ€™t use the term daemon, nevertheless, implement services and processes that perform similar functions.

what is daemon

Daemon History and Development

The concept of daemon comes from the early days of operating systems, especially UNIX, in the late 1960s and early 1970s. The term has its roots in Greek mythology, where daemons were considered benign nature spirits. Hence, the term was adopted in computing to describe background processes that silently perform tasks without interacting with users.

With the advancement in online services, daemons have become essential for managing web services, email servers, and database systems. They are also crucial for system security, as they monitor system activities to protect against malware and unauthorized access.

Today, the concept of daemons has expanded beyond UNIX, affecting the design of services and processes in other operating systems, such as Windows (which uses the term โ€œservicesโ€ rather than daemons). Furthermore, daemons are a fundamental element of the architecture of distributed systems, cloud computing, and microservices.

Daemon vs. Process

A process is a general term that describes any instance of running a program. As the basic unit of execution in an operating system, it encompasses the program code (โ€œthe executableโ€), its current activity (represented by the program counter), and the resources allocated by the operating system. Interactive processes run user commands, whereas non-interactive processes execute tasks in the background.

A daemon is a specific type of background process that runs independently of user sessions and is usually initiated when the computer boots. Daemons do not have a controlling terminal. Instead, they operate in the background, performing tasks such as managing network connections, monitoring systems, etc. Daemons run until the system shuts down and do not require direct user intervention.

How Does a Daemon Work?

A daemon performs tasks autonomously and continuously without interaction from users as follows:

  1. Initialization. A daemon typically starts when the system boots. During the initialization process, the operating parameters, permissions, and resources required for the daemon to work are set up.
  2. Detachment from the controlling terminal. To ensure continuous operation in the background, the daemon detaches itself from the controlling terminal by forking a child process and terminating the parent process. The child process is then adopted by the init process (PID 1) or its equivalent to ensure the daemon runs independently.
  3. Running in the background. After detaching, the daemon runs in the background to perform a wide range of tasks, such as listening for incoming network connections, managing resources, and executing scheduled tasks. When not performing tasks, daemons enter a sleep state to minimize resource consumption.
  4. Logging and monitoring. Daemons log their activities in system log files, which is important for running diagnostics, auditing, monitoring system health, and ensuring security compliance.
  5. Responding to requests and events. Daemons can be set up to respond to certain events and requests, such as file system changes or system load adjustments. These activities can involve starting or stopping tasks, adjusting resource allocation, or performing specific operations in response to predefined rules or triggers.
  6. Resource management and cleanup. Daemons manage their resources, such as memory, network connections, etc., to prevent leaks and ensure system stability. They also clean up resources when the system shuts down to prevent leaving behind unwanted processes or data.

Daemon Types

There are several types of daemons depending on their functionality and the services they provide.

Web Server Daemons

Web server daemons, typically web browsers, are designed to handle requests for web content from clients and serve the requested internet pages and resources. They listen on specific network ports (e.g., port 80 for HTTP or port 443 for HTTPS) and wait for connections. After receiving the request, the web server interprets it and accesses the requested source to retrieve the file and send it back to the client.

Aside from serving web pages, web server daemons also manage encryption, user authentication, traffic redirection, data compression, etc. Common examples of web server daemons are:

  • Apache HTTP Server. Supports a range of functionalities.
  • Nginx. Provides advanced efficiency and performance.

Note: For an in-depth comparison of these two web servers, consult our knowledge base article Apache vs. Ngnix: A Detailed Comparison.

Database Daemons

Database daemons are critical for managing database operations, including data storage, retrieval, updating, and manipulation. These services run continuously on servers while awaiting database queries. They ensure data integrity, smooth performance, and security through transaction processing, access control, and data synchronization. Database daemons handle large volumes of data and complex queries, providing fast and secure access to information.

Examples of database daemons include:

  • mysqld for MySQL. Widely used in web applications due to its reliability and ease of use.
  • mongod for MongoDB. Used for applications that require scalable, document-oriented storage.
  • postgres for PostgreSQL. Suitable for handling complex queries in relational database environments.

File Server Daemons

File server daemons manage the storage, retrieval, and sharing of files across devices on a network. They enable multiple users and computer systems to access shared files and resources without the need for physical storage transfers. This functionality is essential for organizations that use centralized data storage.

The most well-known examples of file server daemons are:

  • NFS (Network File System). Allows users to mount remote file systems as if they were local.
  • Samba daemon. Enables file and printer sharing across Windows, Linux, and macOS operating systems.

Mail Server Daemons

Mail server daemons handle sending, receiving, and storing email over networks. They process incoming and outgoing messages, performing spam filtering, routing, and delivery. Mail server daemons interact with both client applications and mail servers to ensure the smooth transit of messages. They do so through protocols such as SMTP (Simple Mail Transfer Protocol), POP3 (Post Office Protocol version 3), and IMAP (Internet Message Access Protocol).

Examples of mail server daemons include:

  • Postfix. Known for its efficiency, ease of configuration, and robust security.
  • Sendmail. One of the oldest mail server daemons, complex to configure but flexible and powerful.
  • Exim. Highly customizable, allowing scripting for specific mail handling rules.

Print Server Daemons

Print server daemons are essential for managing the distribution and queuing of print jobs among printers and users. They accept and process print requests, ensuring their execution on the appropriate printer hardware. Print server daemons also enable efficient resource sharing through prioritization based on policies or user requirements.

One of the most common examples of print server daemons is CUPS (Common Unix Printing System). Used widely in UNIX-like operating systems, it offers features such as printer sharing, page description languages (PDLs) support, and driver management. CUPS easily integrates into network infrastructures to simplify the management of printing services across hardware and OS environments.

SSH Daemons

SSH daemons are critical for securing network communication. They listen for incoming connections to offer a secure method for executing commands and transferring files over potentially unsecured networks. The SSH protocol encrypts the connection between the client and server to protect it from eavesdropping, interception, and misuse.

SSH daemons are widely used in Unix, Linux, and Windows operating systems. SSH supports many authentication methods, such as password-based authentication, public key authentication, and two-factor authentication, to enhance security across the network. It is widely applicable in commercial and open-source environments because of its reliability and effectiveness in securing remote communications.

FTP Daemons

FTP daemons are crucial for facilitating the transfer of files between systems over a TCP/IP network. They manage user authentication and the process of listing, transferring, and manipulating files according to permissions. They support various modes of verification, including anonymous FTP (File Transfer Protocol), which allows users to download files without a user account and authenticated access.

Prominent examples of FTP daemons include:

  • vsftpd (Very Secure FTP Daemon). Focuses on security and speed and is commonly used in Linux distributions.
  • ProFTPD. Highly customizable, allowing administrators to add or remove features as needed.
  • Pure-FTPd. Noted for its straightforward setup process and the balance of security and performance.

System Monitoring Daemons

System monitoring daemons maintain the health and performance of computer systems and networks. They run continuously, collecting data on various system metrics, such as CPU usage, memory consumption, disk activity, and network traffic. By keeping a close watch on the system, they help administrators detect potential issues before they escalate.

Common examples of system monitoring daemons include:

  • Nagios. Renowned for extensive monitoring features, plugins, and scripts.
  • Zabbix. Offers real-time monitoring of servers, virtual machines, and network devices.
  • Prometheus. Designed for dynamic cloud environments that require collecting time-series data and complex alerting support.

DNS Daemons

DNS (Domain Name System) daemons translate human-friendly domain names into IP addresses that computers use to identify each other. They run on DNS servers and listen for client requests. After receiving them, they search the database to match the domain name with its corresponding IP address to establish a connection.

The most common examples of DNS daemons are:

  • BIND (Berkeley Internet Name Domain). The most widely used DNS software, supports a vast array of DNS records and configurations.
  • Unbound. Designed to be lightweight and secure through the use of DNSSEC (Domain Name Security Extensions).

Daemon Examples

The table below provides an overview of the most common daemon examples mentioned above, including their names, executable code, and primary uses:

Daemon NameExecutable CodePrimary Use
Apache HTTP Serverโ€˜httpd'Web server daemon for serving web pages.
Nginxโ€˜nginxโ€™High-performance web server and reverse proxy.
MySQLโ€˜mysqldโ€™Database server daemon for managing SQL databases.
MongoDBโ€˜mongodโ€™Document-oriented database server daemon.
NFS (Network File System)โ€˜nfsdโ€™File server daemon for sharing files over a network.
Sambaโ€˜smbdโ€™File and print services for SMB/CIFS clients.
Postfixโ€˜postfixโ€™Mail server daemon for handling email delivery.
Sendmailโ€˜sendmailโ€™Mail transfer agent for sending and receiving email.
CUPS (Common UNIX Printing System)โ€˜cupsdโ€™Print server daemon for managing print jobs and queues.
sshd (Secure Shell Daemon)โ€˜sshdโ€™Secure shell server for encrypted remote administration.
vsftpd (Very Secure FTP Daemon)โ€˜vsftpdโ€™FTP server daemon for secure file transfers.
Nagiosโ€˜nagiosโ€™System and network monitoring daemon.
BIND (Berkeley Internet Name Domain)โ€˜namedโ€™DNS server daemon for translating domain names.

Anastazija
Spasojevic
Anastazija is an experienced content writer with knowledge and passion for cloud computing, information technology, and online security. At phoenixNAP, she focuses on answering burning questions about ensuring data robustness and security for all participants in the digital landscape.