Skip to content

What it is

A daemon is a background process detached from the terminal, running continuously to provide a service or perform scheduled work.

A daemon has no terminal. It does not read from stdin, does not write to stdout unless redirected, and does not die when the user logs out. It starts at boot (via init, systemd, launchd, or Windows Service Control Manager), runs for hours, days or years, and is restarted if it crashes. Common daemons: sshd (SSH server), cron (scheduler), nginx (web server), mysqld (MySQL), systemd-journald (log collector), dockerd (Docker).

The daemonizing process is a sequence: fork, setsid, fork again (to prevent reacquiring a terminal), chdir to root (or a fixed dir), reset umask, close inherited file descriptors, redirect 0/1/2 to /dev/null. Modern systems use systemd's Type=simple or Type=forking to manage this without the process daemonizing itself.