CompTIA Linux+ (XK0-006)TroubleshootingHard
A technician checks a failed service: `systemctl status app.service` shows: `Active: failed (Result: exit-code)` Running `journalctl -u app.service -xe` reveals: `Permission denied` when the application attempts to open `/var/lib/app/data.db`. The file is owned by root:root with mode 600, but the service runs as user `appuser`. What should the technician do to resolve this?
- AChange the file ownership with `chown appuser:appuser /var/lib/app/data.db`
- BRun `systemctl daemon-reload` to reload the unit file and clear the error
- CEdit /etc/passwd to change appuser's UID to 0
- DRestart the service repeatedly until it starts successfully
Show answer & explanationAnswer & explanation
Correct answer: A. Change the file ownership with `chown appuser:appuser /var/lib/app/data.db`
The journalctl log clearly shows a permission denied error caused by ownership mismatch: the file is owned by root with restrictive mode 600, but the service process runs as appuser, which has no access. Changing ownership to appuser (or appropriate group) resolves the access issue without weakening security by making the file world-readable or granting root privileges.
Why the other options are wrong
- B. daemon-reload only reloads systemd unit definitions; it does not fix filesystem permissions.
- C. Granting appuser UID 0 (root) is a severe security risk and not the appropriate fix for a single file permission issue.
- D. Repeated restarts won't fix a persistent permission mismatch; it will keep failing.
Service Failure via journalctl
journalctl -u <service> -xe shows detailed logs including the exact error causing a systemd service failure, such as permission issues, missing files, or configuration errors.
- systemctl status shows high-level state (active/failed) and Result reason
- journalctl -u <service> -xe shows extended log entries with context
- Common causes: wrong file ownership/permissions, missing dependencies, bad config syntax
Memory trick: status tells you IT failed, journalctl tells you WHY