Home

WantedBy

WantedBy is a directive used in the Install section of a systemd unit file. It lists units, typically targets, that should cause this unit to be started when they are reached. In practice, WantedBy guides systemd to create installation-time links so that enabling the unit ties it to the specified targets.

How it works: when you enable a unit with systemctl enable, systemd creates symbolic links in the

Relationship to other concepts: WantedBy represents a weak, install-time relationship. It is distinct from a unit’s

Example: a service might include

[Install]

WantedBy=multi-user.target

systemctl enable myservice.service

This creates a link in /etc/systemd/system/multi-user.target.wants/ pointing to the service. Disabling removes the link. The unit

target’s
want
directory
(for
example,
/etc/systemd/system/multi-user.target.wants/).
Each
link
points
to
the
unit
file.
When
a
target
is
started,
systemd
starts
all
units
that
are
listed
in
their
Wants,
Requires,
or
Propagates
relationships,
including
those
that
appear
in
a
unit’s
WantedBy.
If
a
unit
has
multiple
WantedBy
entries,
enabling
it
will
produce
links
in
multiple
targets’
wants
directories,
making
the
unit
start
when
any
of
those
targets
are
activated.
runtime
dependencies
and
from
RequiredBy,
which
is
a
stronger,
demand-based
relationship.
WantedBy
allows
administrators
to
designate
common
startup
runlevels
or
environments,
such
as
multi-user.target
or
graphical.target,
without
hard-coding
mandatory
dependencies.
can
be
started
immediately
with
systemctl
start
and
can
be
activated
on
boot
by
enabling.