EX200 Essential Tools Practice Question
A script needs to be run at system boot for a specific user. Which method ensures the script runs with that user's environment?
⚠ Common exam trap
Test-takers frequently assume @reboot in crontab runs with the full user environment, but in reality cron provides a stripped-down environment (e.g., no D-Bus, no systemd user session), making it unsuitable for scripts that depend on user-specific services or graphical session variables.
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 systemd user unit in ~/.config/systemd/user/
Systemd user units, placed in ~/.config/systemd/user/, are executed in the user's own session context, inheriting the user's environment variables, PATH, and D-Bus session. This ensures the script runs with the specific user's environment at boot, as systemd starts the user manager (systemd --user) early in the boot process for each enabled user.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Place the script in /etc/rc.d/rc.local
Why it's wrong here
Placing the script in /etc/rc.d/rc.local executes it as root during the system boot sequence, outside any user login session. As a result, the script would not run under the specified user's identity and would lack that user's environment variables, HOME, and user-level D-Bus session, so it cannot reliably perform user-specific tasks. Modern distributions also favor systemd units over rc.local for boot-time commands.
- ✗
Add an entry to ~/.xprofile
Why it's wrong here
~/.xprofile is a shell script sourced only by display managers when a user starts a graphical login session, not at system boot. Even if the script runs, it does so well after boot, only when the user logs into the desktop, and its environment is tied to X11/Wayland session startup, not to the user's user manager. Furthermore, systemd user services are a more robust way to handle per-user boot-time needs.
- ✓
Create a systemd user unit in ~/.config/systemd/user/
Why this is correct
A systemd user unit placed in ~/.config/systemd/user/ is managed by the per-user systemd manager and runs in the user's own runtime context, with access to the user's environment, PATH, and systemd user D-Bus. To have it launch at boot rather than only after login, the user must be enabled for lingering (loginctl enable-linger username), after which the user manager starts automatically at boot. This makes it the correct choice for boot-time per-user scripts.
- ✗
Add the script to the user's crontab with @reboot
Why it's wrong here
@reboot entries in a user's crontab run as that user, not as root. However, cron provides a stripped-down environment (no D-Bus, systemd user session), making it less ideal for scripts that depend on the full user environment.
Go deeper
Related to this question
About these practice questions
One of 127 original EX200 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 EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.