Courseiva
Administrative Tasks →hardMultiple Choice

LPIC-1 Administrative Tasks Practice Question

A systemd service unit file must be configured to automatically restart the service if it exits unexpectedly. Which directive should be used?

⚠ Common exam trap

It's easy for candidates to confuse `Restart=always` with `Type=forking` or `RemainAfterExit=yes`, mistakenly thinking these directives handle automatic restarts, when in fact they address process forking or service state after exit.

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

✓

Restart=always

The `Restart=always` directive in a systemd service unit file instructs systemd to automatically restart the service regardless of the exit status, including unexpected crashes or terminations. This ensures high availability by restarting the process whenever it exits, unless explicitly stopped by systemctl. Other directives like `Type=forking` or `RemainAfterExit=yes` do not control restart behavior.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Type=forking

    Why it's wrong here

    Type=forking tells systemd the process daemonises, so it tracks the parent's exit rather than the service's ongoing state; it does not trigger restarts. It is tempting because forking services genuinely need this directive so systemd waits for the parent to exit before considering startup complete — but restart behaviour comes from Restart=, not Type=.

  • ✓

    Restart=always

    Why this is correct

    Restart=always instructs systemd to relaunch the unit whenever its main process terminates, regardless of exit status, satisfying the requirement to recover from unexpected exits. Other Restart values such as on-failure ignore clean exits, so they would not cover every case.

  • ✗

    RemainAfterExit=yes

    Why it's wrong here

    RemainAfterExit keeps the unit marked active after its main process exits, which suits oneshot units, not crash recovery. Restart=on-failure is the directive that relaunches a service after an unexpected exit; RemainAfterExit would leave a failed daemon reported as running and never restarted.

  • ✗

    ExecStop=/bin/true

    Why it's wrong here

    ExecStop defines commands run when the service is deliberately stopped, so it cannot trigger restarts after unexpected exits; that behaviour belongs to Restart=. It is tempting because ExecStop is genuinely used to clean up resources during an orderly shutdown, which would be the right directive if the requirement were graceful termination handling.

About these practice questions

This LPIC-1 question is part of Courseiva's 402-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 by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LPIC-1 practice question is part of Courseiva's free LPI 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 LPIC-1 exam.