Redhat Linux 9: HIểu rõ vai trò và cấu trúc của Target Unit
Link playlist
Red Hat Enterprise Linux Administration
2023 12 26 15 23 20
Understanding Target Units
Behind a target there is some configuration. This configuration
consists of two parts:
The target unit file
The “wants” directory, which contains references to all unit
files that need to be loaded when entering a specific target
Targets by themselves can have dependencies to other targets,
which are defined in the target unit file. Example 17-1 shows
the definition of the multi-user.target file, which defines the
normal operational state of a RHEL server.
Example 17-1 The multi-user.target File
Click here to view code image
[root@localhost ~]# systemctl cat multi-user.tar
# /usr/lib/systemd/system/multi-user.target
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribut
# under the terms of the GNU Lesser General Pub
published by
# the Free Software Foundation; either version
or
# (at your option) any later version.
[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes
You can see that by itself the target unit does not contain much.
It just defines what it requires and which services and targets it
cannot coexist with. It also defines load ordering, by using the
After statement in the [Unit] section. The target file does not
contain any information about the units that should be
included; that is, in the individual unit files and the wants
(explained in the upcoming section “Understanding Wants”).
Systemd targets look a bit like runlevels used in older versions
of RHEL, but targets are more than that. A target is a group of
units, and there are multiple different targets. Some targets,
such as the multi-user.target and the graphical.target, define a
specific state that the system needs to enter. Other targets just
bundle a group of units together, such as the nfs.target and the
sound.target. These targets are included from other targets,
such as multi-user.target or graphical.target.
by Le Hoang Long Long
linux foundation