nerdexam
CompTIA

XK0-005 · Question #10110

An administrator needs to look at a log for an application on a systemd-based system. There is no log for this application in /var/log. Which of the following is another way to view the application…

The correct answer is B. journalctl -u application. On systemd-based systems, application logs that are not written to /var/log can often be found in the systemd journal using the journalctl command.

System Management

Question

An administrator needs to look at a log for an application on a systemd-based system. There is no log for this application in /var/log. Which of the following is another way to view the application log on this system?

Options

  • Atail -f /var/log/secure
  • Bjournalctl -u application
  • Csystemctl application.service
  • Dwatch /var/lib/application/

How the community answered

(48 responses)
  • A
    8% (4)
  • B
    88% (42)
  • C
    2% (1)
  • D
    2% (1)

Why each option

On systemd-based systems, application logs that are not written to `/var/log` can often be found in the systemd journal using the `journalctl` command.

Atail -f /var/log/secure

tail -f /var/log/secure would display logs from the system's security log file, not necessarily the specific application's log if it's not writing there.

Bjournalctl -u applicationCorrect

For systemd-based systems, applications managed by systemd often log to the systemd journal, which `journalctl` can query. The `-u application` option allows filtering logs specifically for a systemd unit named 'application', even if they are not explicitly written to a file in `/var/log`. This is a common method for viewing logs when traditional file-based logging is not used or is redirected to the journal.

Csystemctl application.service

systemctl application.service is used to manage (start, stop, status) systemd services, not to view their logs directly.

Dwatch /var/lib/application/

watch /var/lib/application/ would repeatedly execute a command, in this case `ls` on /var/lib/application/, which would show directory contents but not application logs.

Concept tested: Viewing systemd journal logs

Source: https://man7.org/linux/man-pages/man1/journalctl.1.html

Topics

#systemd#logging#journalctl#system administration

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice