Frequently Asked Question
What is a daemon and how is it different from a normal background process?
A daemon is a long-running background process designed to run unattended, typically
starting at boot and surviving the lifetime of any user session. The classic test
is that it has no controlling terminal, ps shows ? in the TTY column, and its
parent is PID 1 because it was launched by the init system rather than by a login
shell. Names traditionally end in d: sshd, crond, systemd, httpd,
dockerd.
Historically a program "became a daemon" by going through a ritual (fork, leave the
process group, fork again, close all file descriptors, chdir to /, set the
umask). On a systemd system you almost never write that code yourself: you write a
.service unit declaring Type=simple (or notify), and systemd handles the
backgrounding, logging to the journal, restart on failure, and resource limits.
A backgrounded shell job, by contrast, still has a parent shell, a controlling
terminal, and dies when the user logs out, those are the things daemonisation
strips away.