Daemons at your Service

In the days of UNIX, there were programs, users, and daemons. The Devil doth decreed the daemon was good!

A daemon is so-named after a thought experiment known as Maxwell’s Demon, in which a hypothetical demon worked in the background in such a way to theoretically violate the 2nd law of thermodynamics. The thermodynamics are not relevant here, but the concept of an autonomous “background operator” is.

A UNIX daemon typically ends with a “d”, to signify its intended operation.

Here is a short list of commonly-used daemons, and a description of what they do:

  • initd — The Unix program which spawns all other processes. As of 2016, for major Linux distributions, it has been replaced by systemd
  • crond — Time-based job scheduler, runs jobs in the background.
  • dhcpd — Dynamically configures TCP/IP information for clients.
  • httpd — Web server (provided HTML over HTTP)
  • inetd — Listens for network connection requests. If a request is accepted, it can launch a background daemon to handle the request. Some systems use the replacement command xinetd
  • lpd — The line printer daemon manages printer spooling.
  • nfsd — Processes NFS (Network File System) messages from client systems.
  • ntpd — The NTP (Network Time Protocol) daemon manages clock synchronization across the network.
  • sshd — Listens for secure shell requests from clients and provides a remote terminal.
  • syslogd — System logger process that collects various system messages.
  • systemd — Spawns all other processes and services. A replacement of initd.

You can see from the descriptions above that these functions are fairly mundane, somewhat boring, and handle tasks that a logged-in user would not want to be involved with.

So in summary, think of a daemon as a helpful process that runs in the background to keep your system working optimally.

Daemons are also referred to as “services”. Service is more intuitive, so I will use it from here.

Viewing Services

In Ubuntu, systemd has taken the place of initd. It is used to manage, start, stop, and control services on the running system.

The command to work with services in Ubuntu is systemctl. To see it in action, open a terminal and execute the following command:

devil@ubuntuVM:~$ sudo systemctl status

It will display a long list, followed by lines 1-23. Use the up/down and pgup/pgdown keys to navigate until the end. When you are done, type “q” to exit.

Notice in the bottom third of the list, the following section appears:

         │ └─567 /usr/sbin/irqbalance --foreground
         │ └─892 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh
         │ └─283 /lib/systemd/systemd-udevd
         │ └─722 /usr/bin/whoopsie -f
         └─553 /usr/sbin/cron -f
         │ └─571 /usr/lib/policykit-1/polkitd --no-debug
         │ └─568 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startu>
         │ └─925 /usr/libexec/rtkit-daemon
         │ └─548 /usr/lib/accountsservice/accounts-daemon
         │ └─550 /usr/sbin/anacron -d -q -s
         │ └─591 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
         │ └─678 /usr/sbin/ModemManager --filter-policy=strict
         │ └─244 /lib/systemd/systemd-journald
         │ └─683 /usr/bin/python3 /usr/share/unattended-upgrades/unattended>
         └─1352 /usr/libexec/colord
         │ └─557 /usr/sbin/NetworkManager --no-daemon
         │ └─584 /usr/lib/snapd/snapd
         │ └─888 /usr/sbin/gdm3
         │ └─585 /usr/libexec/switcheroo-control
         │ └─579 /usr/sbin/rsyslogd -n -iNONE
         │ ├─726 /usr/sbin/kerneloops --test
         │ └─728 /usr/sbin/kerneloops
         │ └─675 /usr/sbin/cups-browsed
         │ └─667 /usr/sbin/cupsd -l
         │ └─1019 /usr/lib/upower/upowerd
         │ └─520 /lib/systemd/systemd-resolved
         │ └─589 /usr/lib/udisks2/udisksd
         │ └─549 /usr/sbin/acpid
         │ └─556 /usr/bin/dbus-daemon --system --address=systemd: --nofork >
         │ ├─552 avahi-daemon: running [ubuntuVM.local]
         │ └─601 avahi-daemon: chroot helper
           └─588 /lib/systemd/systemd-logind

I won’t list all of the purposes of these services, but you may see a few familiar names in there. In particular, rsyslog, cron, and systemd stand out.

Services in systemd are divided into various slices. The first slice is known as user.slice, and it contains all services started by the active user. This will mostly be filled with desktop programs that manage logins, sound devices, network files, removable media (USB, CD/DVD), etc. The slice I highlighted above is system.slice which contains services that apply system-wide (i.e. they affect all users).

Enabling and Starting Services

Pretend for a moment that we install a new package called devild that manages your system’s cache of memes. If you wanted to ensure it was always active, you would issue the following command:

devil@ubuntuVM:~$ sudo systemctl enable devild

Note: none of these commands will actually work, since there is no service called devild (yet).

If you want to enable it at boot time, plus start it immediately, include the --now option:

devil@ubuntuVM:~$ sudo systemctl enable --now devild

Similarly if you wanted to disable it, issue the following command:

devil@ubuntuVM:~$ sudo systemctl disable devild

To view the status of any service, issue the following command:

devil@ubuntuVM:~$ sudo systemctl status devild



See also