LFCS Service Configuration Practice Question
A system administrator is managing a web application running as a systemd service on a new Linux server. The application requires a specific environment variable, DATABASE_URL, to be set before starting. The administrator has created a custom service unit file at /etc/systemd/system/webapp.service with the following content:
[Unit]
Description=Web Application Service
[Service]
ExecStart=/usr/local/bin/webapp Restart=on-failure
The administrator prefers to keep configuration separate from the unit file for easier updates. The service fails to start. Upon investigation, the administrator notices that the DATABASE_URL variable is not being passed to the process. What is the most appropriate course of action to ensure the environment variable is correctly set?
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
✓
Add EnvironmentFile=/etc/webapp.env in the [Service] section and place the variable in that file
Using EnvironmentFile allows the administrator to keep the DATABASE_URL variable in a separate file, which can be updated without modifying the unit file. Option A hardcodes the variable in the unit file, reducing flexibility. Option C only sets the variable in the current shell session and does not persist for the service. Option D modifies ExecStart but is less standard and less maintainable than using EnvironmentFile.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Add an Environment directive in the [Service] section: Environment=DATABASE_URL=value
Why it's wrong here
Hardcodes the value, less flexible.
- ✓
Add EnvironmentFile=/etc/webapp.env in the [Service] section and place the variable in that file
Why this is correct
Keeps configuration separate, easy to update.
- ✗
Export the DATABASE_URL variable in the shell before running systemctl start webapp
Why it's wrong here
Only applies to the current shell session, not persistent.
- ✗
Modify the ExecStart line to: ExecStart=/usr/bin/env DATABASE_URL=value /usr/local/bin/webapp
Why it's wrong here
Not standard and clutters the unit file.
Go deeper
Related to this question
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 →
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.