Courseiva
Service ConfigurationhardMultiple ChoiceObjective-mapped

LFCS Service Configuration Practice Question

A company runs a critical web application on a Linux server. The application is managed by a systemd service called 'myapp.service'. Recently, after a scheduled maintenance reboot, the service failed to start automatically. The administrator manually started it with 'systemctl start myapp' and it ran fine. The unit file is located at /etc/systemd/system/myapp.service and contains: [Unit] Description=MyApp After=network.target [Service] ExecStart=/usr/local/bin/myapp Restart=on-failure [Install] WantedBy=multi-user.target. The administrator wants to ensure the service starts automatically after future reboots. However, after running 'systemctl enable myapp', the service still didn't start after the next reboot. What is the most likely cause?

⚠ Common exam trap

Test-takers frequently confuse 'After=' with a dependency directive, assuming ordering implies requirement, and overlook that 'Restart=on-failure' only applies to runtime failures, not initial start failures due to unmet conditions.

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

The service depends on a target that is not reached before the service starts, and 'Restart=on-failure' does not retry the start if the condition is not met.

The 'After=network.target' directive only specifies ordering, not a requirement. If the network target is not fully reached before the service starts, systemd will attempt to start the service once and, if it fails, 'Restart=on-failure' will restart it only if the start was successful but the process later exits with a failure. It does not retry the initial start if a dependency condition is not met. The service must have 'Requires=network.target' or 'Wants=network.target' to ensure the target is active before the service starts.

Answer analysis

Option-by-option breakdown

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

  • The 'systemctl enable' command only creates symlinks; a separate 'systemctl start' must be run after enable.

    Why it's wrong here

    Enable is for boot start, not immediate start; but the service should start at boot.

  • The service depends on a target that is not reached before the service starts, and 'Restart=on-failure' does not retry the start if the condition is not met.

    Why this is correct

    With After=network.target, the service may start before network is fully ready; on-failure only restarts if the service exits with non-zero, but if the start fails due to a condition (e.g., network not ready), the service may not be restarted. Using 'Restart=always' or 'RestartSec' can help.

  • The 'systemctl enable' command was not run as root.

    Why it's wrong here

    Even if not root, it would have given an error; but the command succeeded as stated.

  • The unit file has a syntax error that prevents systemd from parsing it.

    Why it's wrong here

    If there were a syntax error, manual start would also fail.

About these practice questions

One of 507 original LFCS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

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.