LFCS Operation of Running Systems Practice Question
An administrator needs to ensure that a custom service, /usr/local/bin/monitor.sh, starts automatically at boot and is restarted if it crashes. The service should run as user 'monitor' and should not depend on network being online. Which systemd unit file configuration is most appropriate?
⚠ Common exam trap
The trap here is assuming that Restart=on-failure covers all crash scenarios, but a script might exit with status 0 even after an internal error.
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
✓
Create a unit file with [Service] Type=simple, ExecStart=/usr/local/bin/monitor.sh, Restart=always, User=monitor, and [Install] WantedBy=multi-user.target.
A systemd service unit must specify the correct Type, ExecStart, Restart policy, User, and installation target. For a script that runs in the foreground, Type=simple is suitable. Restart=always ensures the service is restarted regardless of exit status, providing resilience. User=monitor runs it with least privilege. WantedBy=multi-user.target enables start at boot without network dependency. This combination satisfies all stated requirements.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create a unit file with [Service] Type=simple, ExecStart=/usr/local/bin/monitor.sh, Restart=on-abnormal, User=monitor, and [Install] WantedBy=multi-user.target.
Why it's wrong here
Restart=on-abnormal restarts only on abnormal termination (e.g., signal, timeout). If the script exits with a non-zero status due to a crash, it may not restart. The requirement is to restart if it crashes, which could include clean exits with errors. Restart=always is more robust for ensuring continuous operation.
- ✓
Create a unit file with [Service] Type=simple, ExecStart=/usr/local/bin/monitor.sh, Restart=always, User=monitor, and [Install] WantedBy=multi-user.target.
Why this is correct
This configuration defines a simple service that runs the script, restarts on any exit, runs as the specified user, and is enabled at boot via multi-user.target. It meets all requirements: automatic start, restart on crash, user context, and no network dependency. The Type=simple is appropriate for a script that does not fork.
- ✗
Create a unit file with [Service] Type=simple, ExecStart=/usr/local/bin/monitor.sh, Restart=always, User=monitor, and [Install] WantedBy=graphical.target.
Why it's wrong here
WantedBy=graphical.target means the service starts only when the graphical target is reached. On a server without a graphical interface, it would never start. The requirement is to start at boot regardless of graphical mode, so multi-user.target is more appropriate. This configuration would fail to meet the automatic start requirement.
- ✗
Create a unit file with [Service] Type=forking, ExecStart=/usr/local/bin/monitor.sh, Restart=on-failure, User=monitor, and [Install] WantedBy=network-online.target.
Why it's wrong here
Type=forking expects the script to fork and exit, which monitor.sh likely does not. Restart=on-failure would not restart on clean exits, and WantedBy=network-online.target introduces a network dependency, violating the requirement. This unit would not function as intended and may fail to start properly.
Go deeper
Related to this question
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 →
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.