Table of Contents
- Special units
X-<name>for non-standard sections
[Section] Directive1=value Directive2=value ...
|type of unit||description|
||manage a service or application on the server|
||synchronization points for other units when booting up or changing states|
- Target units do not offer any additional functionality on top of the generic functionality provided by units.
- They exist merely to group units via dependencies
||runt-ime unit definitions|
||overrides (unit files which take precedence)|
||Usually, this should be aliased (symlinked) to
- The first section found in most unit files
- Defines metadata for the unit and configuring the relationship of the unit to other units.
- activate dependenceis and fail if they fail
- activate dependencies but don't care whether they fail or not
- fails if the dependency is not active
- deactivate the dependency if it is active
- Defines configuration that is only applicable for services
- how to manage services.
forkingfor services which fork,
oneshotfor shot-lived process
oneshottype. active after process exits
- if path to command starts with
-, systemd considers active even if it's failed
- if not given, the process will be killed when stopped
- When stopping, after waiting
nseconds, systemd kills the process
- The last section is often
- Defines the behavior or a unit if it is enabled or disabled
- Enabling a unit marks it to be automatically started at boot.
[Unit] ... [Service] ... [Install] WantedBy=multi-user.target
sshd.service, systemd adds it to
multi-user.target by following:
systemctl start <name>.service systemctl stop <name>.service systemctl restart <name>.service systemctl reload <name>.service # reload some configs while running systemctl enable <name>.service # make service start at boot systemctl disable <name>.service systemctl status <name>.service # overview systemctl show <name>.service # low-level details systemctl list-dependencies <name>.service systemctl list-units # only active systemctl list-units --all # all loaded systemctl list-unit-files # all installed systemctl cat <name>.service # contents of unit file systemctl edit <name>.service # edit override for unit file systemctl edit --full <name>.service # edit unit file systemctl daemon-reload # reload after edit systemctl list-unit-files --type=target systemctl get-default
Is it expected for systemd to start disabled services?
systemctl disableoperations configure auto-starting of a unit.
So, starting a unit without enabling it is valid.
What is STATE from 'systemctl list-unit-files'?
- it has a symlink in a .wants directory.
- it does not.
- the service is missing the
[Install]section in its init script, so you cannot enable or disable it. Static services are usually dependencies of other services, and are controlled automatically.