RHEL Linux - Red Hat System Administration Practice Exam

Disable ads (and more) with a membership for a one time $4.99 payment

Study for the RHEL Linux - Red Hat System Administration Exam. Enhance your knowledge with flashcards and multiple-choice questions, complete with hints and explanations. Prepare for your certification!

Practice this question and more.


Which command is used to view the logs for a service managed by systemd?

  1. journalctl -u [service]

  2. systemctl logs [service]

  3. service [service] status

  4. tail -f /var/log/[service].log

The correct answer is: journalctl -u [service]

The command that is used to view the logs for a service managed by systemd is indeed the one that employs `journalctl -u [service]`. This command interacts with the journal, which is a component of systemd responsible for logging service messages. By specifying the `-u` option followed by the name of the service, you can retrieve logs specifically related to that service, showing all relevant entries from the journal. Using this command provides a comprehensive view of the service's logs, including error messages, informational logs, and other output that the service may generate. This is especially useful for troubleshooting issues related to the service's operation, as it allows administrators to see real-time and historical logs in a structured way. In contrast, the other options do not accurately retrieve logs in the same way. For instance, the second option, which mentions `systemctl logs [service]`, does not exist as a valid command, as `systemctl` does not directly handle log retrieval. The third option, `service [service] status`, retrieves the status of the service but does not provide access to the log entries themselves. Lastly, using `tail -f /var/log/[service].log` implies that logs are stored in a standard log file