I am new to systemd fundamentals. I read sth about systemd units and unit files and services. Would someone please define these three terms for me clearly ? I'm mixed up .Also what is a daemon ? is daemon a service or unit or is it sth else? Does units are objects or handles to manage services by systemd or units are equivalent to services? Also for example when you type the command "systemctl list-units " or "systemctl list-units-files" ,do these commands print units and unit files or services? Thank you in advance.
1 Answer
man systemd.unit
, man systemd
, and man systemd.service
should answer most of your questions.
I read sth about systemd units and unit files and services. Would someone please define these three terms for me clearly ?
systemd provides a dependency system between various entities called "units" of 11 different types. Units encapsulate various objects that are relevant for system boot-up and maintenance.
A unit file is a plain text ini-style file that encodes information about a service, a socket, a device, a mount point, an automount point, a swap file or partition, a start-up target, a watched file system path, a timer controlled and supervised by systemd(1), a resource management slice or a group of externally created processes.
A unit configuration file whose name ends in ".service" encodes information about a process controlled and supervised by systemd.
So in short, a systemd service is one of several types of systemd units. Specifically, it usually runs a process. A service configuration file contains rules on how to run/restart/exit that process in the [Service]
section of the file. Service-specific options are detailed in man systemd.service
, man systemd.exec
and man systemd.kill
.
Other types of units are things like mount points, sockets, or paths which have their own types of configurations.
But all units have a common set of behaviours, including relationships between them and how they are triggered. You can see what options are available in their [Unit]
or [Install]
sections.
Also what is a daemon ?
Just think of a daemon as a background process. It's what is managed by a systemd service. There's probably a better definition, but it's not quite as relevent in systemd.
do these commands print units and unit files or services?
When you type systemctl list-units
, units are listed (including services, but not only services). You can see things like *.device
, .mount
in addition to the .service
items listed.
-
Wikipedia has a nice section regarding the "daemon" terminology. It originates from "Maxwells Demon", a physics thought experiment.– PankiAug 25, 2022 at 15:47
man systemd.service
andman systemd.unit
? Or any other related documentation?