Linux 101 : Systemd components overview



Services and initialization processes are managed by "systemd" It replaces the "sysvinit" system and its "runlevels".
Systemd also allows us to start different processes simultaneously, resulting in a faster boot time.

  • Systemd manages units
  • Units have different types : socket, service, target,....
  • Unit files contain the configuration of the different units.
Systemd units:

Systemd manages units and the different units represent the system resources that systemd manages. To see all the units in a system, we use:


To see all the units, including the non-active ones we use:


Systemd unit files:

Unit files are configurations files that determines how systemd deals with the units (services, sockets, targets,....).
To list the unit files (configuration files), we use the below command:


We could also see the configuration files by going to "/usr/lib/systemd/system", and displaying its content with the command "ls".

Remark:

Standard files that ship with the system go into "/usr/lib/systemd/system", and any packages installed by "root" for example are stored in "/etc/systemd/system".

Looking inside the configuration files:

To see the content of a configuration file, we use for the ssh service for example:


You can tweak how the system behaves by changing the services that are started and their behaviors. We do that by modifying configuration files of these services. Modifications are done to the target files, service files,..., in "/etc/systemd/system".

Unit types:

We have different unit types, to see all the types, we use:


To list the "service" unit files for example, we use:


Systemd targets:

Targets represent different "states" of the system, where only a group of resources are available (services, sockets, other targets,...).
To get the default target "state" we use:


Listing all the targets on system:


We can list a specific service using the grep command:


Switching between targets:

To go into a command line - multi-user "state" we use:


To set the "multi-user.target" as the default state at boot time, we use:


Targets dependencies:

We can list the dependencies of a target that are required for it to work properly, using the below command. In this example, we show the dependencies of the "graphical.target" target:


Service dependencies:

To list "sshd" service dependencies for example, we use:


Rebooting and powering off a system:

To power off a system, we use the below command:


To reboot the system, we use the below command:


To boot into rescue mode -single user environment- to troubleshoot the system, we use:


Comments

Leave as a comment:

Archive