LFCS Service Configuration Practice Question
A system administrator is creating a systemd service unit for a custom application. The application requires that a specific environment variable, APP_ENV=production, be set before the service starts. The administrator wants this variable to be available only to this service, not system-wide. Which directive should be used in the service unit file?
⚠ Common exam trap
A common mix-up: candidates confuse Environment= with PassEnvironment=, or assuming EnvironmentFile= is required for any environment variable.
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
✓
Environment=APP_ENV=production
The Environment= directive in a systemd service unit sets environment variables specifically for that service. It does not affect the system-wide environment. EnvironmentFile= requires an external file, SetEnvironment= is not a valid directive, and PassEnvironment= only forwards existing variables from the manager. Therefore, Environment= is the correct choice.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Environment=APP_ENV=production
Why this is correct
Environment= sets environment variables for the executed process. It can be used multiple times to set multiple variables. This directive applies only to the service unit, not system-wide, and is the correct way to set a service-specific environment variable. It is placed in the [Service] section of the unit file.
- ✗
PassEnvironment=APP_ENV
Why it's wrong here
PassEnvironment= is used to pass environment variables from the systemd manager's environment to the service. It does not set a new value; it only forwards existing variables. Since APP_ENV=production is not already set in the manager's environment, this directive would not set it. It is used in conjunction with variables set elsewhere, such as in the systemd manager's environment.
- ✗
EnvironmentFile=/etc/sysconfig/myapp
Why it's wrong here
EnvironmentFile= reads environment variables from a file. While it can be used to set variables for the service, it requires an external file to exist and contain the variable. The scenario does not mention an external file; the administrator wants to set a specific variable directly. This directive could work if the file is created, but it is not the most direct or appropriate method when the variable is known and static.
- ✗
SetEnvironment=APP_ENV=production
Why it's wrong here
SetEnvironment= is not a valid systemd directive. The correct directive is Environment=. Using an invalid directive would cause systemd to ignore it or fail to parse the unit file, depending on the systemd version. This option is a distractor and does not achieve the desired configuration.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LFCS question from scratch — 406 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.