RHCSA RHCSA Systemd and Service Management 5 — Questions and Answers
Question 1: Which directive in a unit file's `[Service]` section sets environment variables for the process?
- EnvFile=
- Environment= (Correct answer)
- EnvSet=
- SetEnv=
Correct answer: Environment=
`Environment=` sets key=value environment variables directly in the unit file's `[Service]` section.
Question 2: How do you make journald persist logs across reboots on a RHEL system where it is not yet doing so?
- Set Storage=persistent in /etc/systemd/journald.conf and restart systemd-journald
- Run journalctl --enable-persistent
- Set PersistLogs=yes in /etc/systemd/system.conf
- Create /var/log/journal/ directory and restart systemd-journald (Correct answer)
Correct answer: Create /var/log/journal/ directory and restart systemd-journald
Creating `/var/log/journal/` causes journald to automatically switch to persistent storage on restart.
Question 3: A unit file has `ConditionPathExists=/etc/myapp.conf`. What happens if that file does not exist when the unit is started?
- The unit fails with an error
- The unit is skipped silently as if it succeeded (Correct answer)
- The unit enters the 'waiting' state
- Systemd creates the file automatically
Correct answer: The unit is skipped silently as if it succeeded
When a `Condition*=` check fails, systemd skips the unit without error — it reports as 'success' but does nothing.
Question 4: Which systemctl subcommand shows all currently loaded and active socket units?
- systemctl list-units --type=socket (Correct answer)
- systemctl show-sockets
- systemctl list-sockets
- systemctl status *.socket
Correct answer: systemctl list-units --type=socket
`systemctl list-units --type=socket` filters the active unit list to show only socket units.
Question 5: What is the correct way to view the full content of a unit file including overrides using systemctl?
- systemctl show httpd.service
- systemctl cat httpd.service (Correct answer)
- systemctl dump httpd.service
- systemctl read httpd.service
Correct answer: systemctl cat httpd.service
`systemctl cat` prints the full unit file content including all applicable drop-in override files.
Question 6: A service has `After=postgresql.service` but NOT `Requires=postgresql.service`. What is the practical effect?
- The service will not start if PostgreSQL is not running
- The service starts after PostgreSQL if PostgreSQL is being started, but starts regardless otherwise (Correct answer)
- The service and PostgreSQL always start together
- The service will restart PostgreSQL if it stops
Correct answer: The service starts after PostgreSQL if PostgreSQL is being started, but starts regardless otherwise
`After=` only controls ordering; without `Requires=` or `Wants=`, there is no dependency — only sequencing if both happen to activate.
Question 7: Which command sets `graphical.target` as the default boot target?
- systemctl default graphical.target
- systemctl set-default graphical.target (Correct answer)
- systemctl enable graphical.target --default
- systemctl link-default graphical.target
Correct answer: systemctl set-default graphical.target
`systemctl set-default graphical.target` updates the `default.target` symlink to point to `graphical.target`.
Which directive in a unit file's `[Service]` section sets environment variables for the process?