If we have the [Requires] directive in the [Unit] part of a service unit file then why do we also need [RequiredBy] directive in the [Install] section of the service unit file..I understand that the directives under the [Install] part is executed when the service is enabled(service has to restart after server reboot) so even if i don't specify the [RequiredBy] directive then also after the server reboot anyways the systemctl is going to check the [Requires] directive and will start the required service/target unit...Please clarify this i am newbie to Systemctl utility.
They do different things. Actually, one is the mirror image of the other.
[Requires]
configures dependencies on other units; the units listed here are activated together with the unit, and if any of them fails to start, the unit is not activated.
[RequiredBy]
specifies a list of units that depend on the unit. When this unit is enabled, the units listed here gain automatically a [Require]
dependency on the unit; consequently you do not need to specify a [Require]
for each of these units.
Source: RHEL7 SysAdmin guide