Courseiva
Service Configuration →easyMultiple Select

LFCS Service Configuration Practice Question

A system administrator needs to ensure that a custom service named 'myapp.service' starts automatically after a reboot and also restarts automatically no matter how the service stops, even if it exits normally. Which two actions should the administrator take? (Choose two.)

⚠ Common exam trap

LFCS often tests the distinction between 'Restart=on-failure' and 'Restart=always' — candidates pick on-failure assuming it covers all cases, but it explicitly excludes clean exits, which the question calls out.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Run 'systemctl enable myapp.service' to enable the service.

Option B is correct because 'systemctl enable myapp.service' creates the necessary symlinks (typically under /etc/systemd/system/*.wants/) so systemd starts the unit automatically at boot, satisfying the reboot requirement. Option D is correct because 'Restart=always' in the [Service] section instructs systemd to restart the service regardless of exit status, including a clean exit code 0, which matches the requirement that it restart no matter how it stops. Option C is incorrect because 'Restart=on-failure' only restarts on non-zero exit codes, signals, or timeouts, so a normal exit would not trigger a restart. Option A is incorrect because 'systemctl mask' links the unit to /dev/null and prevents it from being started at all, the opposite of the desired behavior. Option E is incorrect because 'After=network.target' only orders startup relative to the network target and does not enable boot startup or automatic restarts.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Run 'systemctl mask myapp.service' to prevent manual stops.

    Why it's wrong here

    Masking symlinks the unit to /dev/null, preventing any start, including at boot, and does nothing about automatic restarts. It is tempting as a way to stop manual interference, and would be correct if the goal were to make the service permanently unstartable.

  • ✓

    Run 'systemctl enable myapp.service' to enable the service.

    Why this is correct

    Enabling the unit creates the systemd symlink under the appropriate target's .wants directory, so systemd starts myapp.service automatically at boot. This satisfies the reboot-persistence constraint, complementing the restart behaviour configured separately in the unit file.

  • ✗

    Set 'Restart=on-failure' in the [Service] section of the service file.

    Why it's wrong here

    Restart=on-failure only restarts on non-zero exit, signals or timeouts, so a clean exit leaves the service stopped. It is tempting because it is the standard restart directive, and would be correct if the requirement excluded normal exits.

  • ✓

    Set 'Restart=always' in the [Service] section of the service file.

    Why this is correct

    Restart=always instructs systemd to restart the unit regardless of exit status, including a clean exit code of zero, which Restart=on-failure would not cover. This satisfies the stem's requirement that the service restart no matter how it stops.

  • ✗

    Add 'After=network.target' to the [Unit] section of the service file.

    Why it's wrong here

    Ordering after network.target only sequences startup relative to networking; it does not enable the unit at boot nor restart it on exit. It is tempting because dependencies genuinely control activation ordering, and would be correct if myapp needed network availability before launching.

About these practice questions

This LFCS question is part of Courseiva's 406-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Linux Foundation exam blueprint

This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.