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
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
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
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.
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:
└─system.slice ├─irqbalance.service │ └─567 /usr/sbin/irqbalance --foreground ├─vboxadd-service.service │ └─892 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh ├─systemd-udevd.service │ └─283 /lib/systemd/systemd-udevd ├─whoopsie.service │ └─722 /usr/bin/whoopsie -f ├─cron.service └─553 /usr/sbin/cron -f ├─polkit.service │ └─571 /usr/lib/policykit-1/polkitd --no-debug ├─networkd-dispatcher.service │ └─568 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startu> ├─rtkit-daemon.service │ └─925 /usr/libexec/rtkit-daemon ├─accounts-daemon.service │ └─548 /usr/lib/accountsservice/accounts-daemon ├─anacron.service │ └─550 /usr/sbin/anacron -d -q -s ├─wpa_supplicant.service │ └─591 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant ├─ModemManager.service │ └─678 /usr/sbin/ModemManager --filter-policy=strict ├─systemd-journald.service │ └─244 /lib/systemd/systemd-journald ├─unattended-upgrades.service │ └─683 /usr/bin/python3 /usr/share/unattended-upgrades/unattended> ├─colord.service └─1352 /usr/libexec/colord ├─NetworkManager.service │ └─557 /usr/sbin/NetworkManager --no-daemon ├─snapd.service │ └─584 /usr/lib/snapd/snapd ├─gdm.service │ └─888 /usr/sbin/gdm3 ├─switcheroo-control.service │ └─585 /usr/libexec/switcheroo-control ├─rsyslog.service │ └─579 /usr/sbin/rsyslogd -n -iNONE ├─kerneloops.service │ ├─726 /usr/sbin/kerneloops --test │ └─728 /usr/sbin/kerneloops ├─cups-browsed.service │ └─675 /usr/sbin/cups-browsed ├─cups.service │ └─667 /usr/sbin/cupsd -l ├─upower.service │ └─1019 /usr/lib/upower/upowerd ├─systemd-resolved.service │ └─520 /lib/systemd/systemd-resolved ├─udisks2.service │ └─589 /usr/lib/udisks2/udisksd ├─acpid.service │ └─549 /usr/sbin/acpid ├─dbus.service │ └─556 /usr/bin/dbus-daemon --system --address=systemd: --nofork > ├─avahi-daemon.service │ ├─552 avahi-daemon: running [ubuntuVM.local] │ └─601 avahi-daemon: chroot helper └─systemd-logind.service └─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,
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
If you want to enable it at boot time, plus start it immediately, include the
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
Tip JarIf you're getting value from my writing, please support my efforts with a donation. You can donate directly using my public Ethereum address
bowtieddevil.eth. Or you can use the donation button below, which works through my self-hosted BTCPay Server.