What exactly is a daemon?

A daemon (pronounced DEE-muhn) is a program that runs continuously in the background, designed to handle periodic service requests that the system expects to receive.

What exactly is a daemon?
Image credit: Unknown. Please contact us if you are the owner.


Daemon

A daemon is a background process on Unix/Linux systems that runs independently of user interaction. It typically starts in response to specific system events, conditions, or the initiation of certain services.

These processes are often spawned by other programs and are managed by the system kernel, which assigns each one a unique Process ID (PID). Most daemon process names end with the letter “d” to signify their background nature.

For example:

  • httpd is the daemon that handles Apache web server operations.
  • sshd manages SSH remote access connections.

Interactive, Batch, and Daemon

In Linux, processes are generally categorized into three types:

  1. Interactive Processes
    These are initiated directly by the user via the command line interface (CLI). They run in the foreground and terminate once their task is complete.
  2. Batch Processes
    These are not directly tied to the CLI. Instead, they are queued for execution, typically during low system usage periods. Batch processes are ideal for repetitive or scheduled tasks.
  3. Daemon Processes
    These are background services initiated by the system. Daemons are usually detached from the terminal and operate silently in the background. The initial daemon process is init (or its modern replacement, like systemd), which is the first process started by the Linux kernel during boot. It remains active until the system shuts down.

How Daemons Are Spawned

Daemons are typically created through a technique called forking, where a parent process creates a child process. The parent process then terminates, allowing the child process (the daemon) to continue running in the background, independently handling its designated tasks.





⚠️ Good to remember:
A daemon is always a process, but not all processes are daemons.

We hope this was of great use!

Keep Us Caffeinated  ⦿ ⦿
Icon Join our 32K+ readers