LFCS Certification System Service Management (systemd) 5 — Questions and Answers
Question 1: What is the correct way to make a custom unit file survive system package upgrades?
- Place it in /lib/systemd/system/
- Place it in /usr/lib/systemd/system/
- Place it in /etc/systemd/system/ (Correct answer)
- Place it in /run/systemd/system/
Correct answer: Place it in /etc/systemd/system/
Files in `/etc/systemd/system/` are managed by the administrator and take precedence over vendor files in `/usr/lib/systemd/system/`, surviving package upgrades.
Question 2: A service has `KillMode=control-group` set. What happens when systemd stops it?
- Only the main process (PGID) receives SIGTERM
- All processes in the service's cgroup receive the kill signal (Correct answer)
- The service is killed immediately with SIGKILL without SIGTERM first
- Only processes listed in PIDFile= are killed
Correct answer: All processes in the service's cgroup receive the kill signal
`KillMode=control-group` (the default) sends the kill signal to all processes in the unit's cgroup, preventing orphan processes.
Question 3: Which directive in a unit file's [Unit] section defines a hard dependency where the unit will fail if the dependency is not met?
- Wants=
- Requires= (Correct answer)
- After=
- BindsTo=
Correct answer: Requires=
`Requires=` creates a hard dependency: if the required unit fails to start, the dependent unit also fails, unlike `Wants=` which is a soft dependency.
Question 4: You want to run a one-shot script at every boot without keeping a running process. Which service `Type=` is most appropriate?
- Type=simple
- Type=forking
- Type=oneshot (Correct answer)
- Type=idle
Correct answer: Type=oneshot
`Type=oneshot` tells systemd the service's main process is expected to exit after completing its task, and systemd waits for it to finish before proceeding.
Question 5: Which command shows the overall boot time broken down into firmware, loader, kernel, and userspace phases?
- systemd-analyze blame
- systemd-analyze time (Correct answer)
- systemd-analyze critical-chain
- systemd-analyze verify
Correct answer: systemd-analyze time
`systemd-analyze time` outputs the total boot time split into firmware, boot loader, kernel initialization, and userspace (initrd + system) phases.
Question 6: What does the `ConditionPathExists=/etc/myapp.conf` directive in a unit file do?
- It creates /etc/myapp.conf if it doesn't exist before starting the service
- It skips starting the unit (without failing) if /etc/myapp.conf does not exist (Correct answer)
- It causes the unit to fail if /etc/myapp.conf is missing
- It watches /etc/myapp.conf for changes and restarts the service
Correct answer: It skips starting the unit (without failing) if /etc/myapp.conf does not exist
Condition* directives cause the unit to be skipped (result is 'skipped', not 'failed') if the condition is not met, allowing optional activation.
Question 7: Which command would permanently change the system's default boot target to `graphical.target`?
- systemctl default graphical.target
- systemctl set-default graphical.target (Correct answer)
- systemctl enable graphical.target --default
- ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
Correct answer: systemctl set-default graphical.target
`systemctl set-default graphical.target` updates the `/etc/systemd/system/default.target` symlink to point to graphical.target, making it the persistent default.
What is the correct way to make a custom unit file survive system package upgrades?