Which command shows recent logs for a specific systemd service?

Prepare for the Google Data Center Technician Exam. Use our interactive quiz featuring flashcards and multiple choice questions with hints and explanations. Get exam-ready today!

Multiple Choice

Which command shows recent logs for a specific systemd service?

Explanation:
To view recent logs for a specific systemd service, filter the systemd journal by the service unit. The command that does this uses journalctl with the -u option and the exact service name, which returns only the log entries for that unit. This makes it the most direct way to see recent activity for that service, without mixing in logs from other services. If you were to tail the entire journal with -f, you’d see live updates from everything, not just the chosen service. And while systemctl status can show a quick snapshot, it isn’t a focused log stream for detailed recent entries. So using the unit-filtered journal is the precise method for the task.

To view recent logs for a specific systemd service, filter the systemd journal by the service unit. The command that does this uses journalctl with the -u option and the exact service name, which returns only the log entries for that unit. This makes it the most direct way to see recent activity for that service, without mixing in logs from other services. If you were to tail the entire journal with -f, you’d see live updates from everything, not just the chosen service. And while systemctl status can show a quick snapshot, it isn’t a focused log stream for detailed recent entries. So using the unit-filtered journal is the precise method for the task.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy