Let's take for example the sshd service. The init script file looks something like the below:
Because sshd is a service, most of the "essential" information will be in the "Service" part of the init file.
The information in the "Service" part tells systemd about the service's configuration, commands to use to start it, ...
The "Install" part holds important information in the "WantedBy" and "RequiredBy" parameters, which are dependency parameters - see later -.
Systemd usually doesn't take into account the "Install" section. Systemd reads the "Install" portion of the init file when rebooting the system, for example when we "enable" a service so it is taken into account during a reboot
We can enable a service using the following command:
Systemd reads the "Install" part of the init file to know the dependencies "WantedBy" and "RequiredBy".
The line "WantedBy=multi-user.target" for example tells systemd to creates a symbolic link to the service "sshd.service" in the directory "/etc/systemd/system/multi-user.target.wants".
The "Install" section is responsible for the creation of the "xxxxxx.wants" and "xxxxxx.requires" directories in the system configuration directory "/etc/systemd/system".
We can see in the above example a couple of "xxxxx.wants" and "xxxxx.requires" directories.
They correspond to the "WantedBy" and "RequiredBy" parameter in the "Install" section of the init file.
In the "multi-user.target.wants" directory, we could find for example the below symlinks -symbolic links which refer to services that are started in the "multi-user.target" target- :
To see the above symbolic links more clearly, we use the below command - we see the real location of the services and their symbolic links inside the "mutli-user.target.wants" directory -:
To add dependencies to a service without altering the original init file, we could use the "xxxxx.wants" directory in the following directory "/usr/lib/systemd/system".