CompTIA Linux+ (XK0-006)Services and User ManagementMedium
A system administrator is troubleshooting a service that fails to start at boot. The service unit file, `mydaemon.service`, contains `Requires=network-online.target`. Which of the following commands would help verify if the `network-online.target` is being reached or if there are issues preventing it from being achieved?
- Asystemctl list-dependencies network-online.target
- Bsystemctl status network-online.target
- Cjournalctl -u network-online.target
- Dip a show
Show answer & explanationAnswer & explanation
Correct answer: C. journalctl -u network-online.target
While `systemctl status network-online.target` would show its current state, `journalctl -u network-online.target` is more effective for troubleshooting. It displays log messages specifically related to the `network-online.target` unit, which can reveal why it might be failing or taking too long to activate.
Why the other options are wrong
- A. This command shows what `network-online.target` depends on, which is useful for understanding its structure, but not for diagnosing runtime failures.
- B. This command shows the current state (active/inactive) but not the detailed events leading to that state or potential failures.
- D. This command shows network interface information, which is relevant to network connectivity, but doesn't directly provide `systemd` target status or logs.
journalctl for systemd targets
The `journalctl` utility can be used with the `-u` option to view log messages generated by or related to a specific `systemd` unit, including target units like `network-online.target`.
- Filters logs by unit name.
- Useful for diagnosing target activation issues.
- Provides historical and real-time log data.
Memory trick: JOURNALctl logs all TARGET actions.