Courseiva

LFCS Operation of Running Systems Practice Question

An administrator is investigating why the 'tomcat' service fails to start on a RHEL 8 server. The output of 'systemctl status tomcat' shows: 'Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since ... Process: 4567 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=1/FAILURE)'. The 'journalctl -u tomcat' shows: 'Error: JAVA_HOME is not defined correctly, cannot execute /usr/lib/jvm/java-11-openjdk/bin/java'. The admin checks /opt/tomcat/bin/startup.sh and sees it references JAVA_HOME. The admin verifies that Java 11 is installed at /usr/lib/jvm/java-11-openjdk. Which action should the admin take to fix the service?

⚠ Common exam trap

It's easy for candidates to assume setting environment variables in shell profile files (like `/etc/profile`) will affect systemd services, but systemd does not source these files; the correct method is to use the `Environment=` directive in the unit file.

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 'Environment=JAVA_HOME=/usr/lib/jvm/java-11-openjdk' to the [Service] section of /etc/systemd/system/tomcat.service and run 'systemctl daemon-reload && systemctl restart tomcat'.

Systemd services can have environment variables set via the `Environment=` directive in the unit file. Adding `JAVA_HOME=/usr/lib/jvm/java-11-openjdk` to the `[Service]` section ensures the variable is available to the `ExecStart` process. Running `systemctl daemon-reload` reloads the unit definition, and `systemctl restart tomcat` applies the change. This is the proper method for configuring environment variables for systemd-managed services on RHEL 8.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Edit /opt/tomcat/bin/startup.sh and hardcode JAVA_HOME.

    Why it's wrong here

    Hardcoding JAVA_HOME inside startup.sh bypasses systemd's environment handling and diverges from the packaged script, so the unit still starts with no JAVA_HOME exported. Editing the script is tempting because the error names that variable, but the correct fix sets Environment=JAVA_HOME= in the unit file.

  • ✓

    Add 'Environment=JAVA_HOME=/usr/lib/jvm/java-11-openjdk' to the [Service] section of /etc/systemd/system/tomcat.service and run 'systemctl daemon-reload && systemctl restart tomcat'.

    Why this is correct

    The unit runs startup.sh without a shell profile, so JAVA_HOME is unset in the service environment, causing the exit-code 1 failure. Declaring Environment=JAVA_HOME in the [Service] section injects the variable directly into the unit's environment, satisfying the script's requirement; daemon-reload applies the change.

  • ✗

    Run the startup script manually with 'bash /opt/tomcat/bin/startup.sh'.

    Why it's wrong here

    Running the script manually executes it in the administrator's interactive shell, which already has JAVA_HOME, so it neither fixes the unit's missing environment nor makes systemctl start succeed. Manual invocation is tempting for confirming the script itself works, but systemd services need Environment=JAVA_HOME= in the unit file.

  • ✗

    Set JAVA_HOME globally using 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' in /etc/profile.

    Why it's wrong here

    /etc/profile is read only by login shells, so systemd's ExecStart never sources it and JAVA_HOME remains unset for the unit. Global exports are tempting because they fix interactive sessions, but the correct fix declares Environment=JAVA_HOME= in tomcat.service, which systemd reads directly.

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 →

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.