nerdexam
CompTIA

XK0-005 · Question #475

A development team asks an engineer to guarantee the persistency of journal log files across system reboots. Which of the following commands would accomplish this task?

The correct answer is C. sed -i 's/auto/persistent/g' /etc/systemd/journald.conf && sed -i 'persistent/s/^#//q'. To ensure systemd journal logs persist across system reboots, the Storage parameter in /etc/systemd/journald.conf must be set to persistent and the systemd-journald service restarted.

System Management

Question

A development team asks an engineer to guarantee the persistency of journal log files across system reboots. Which of the following commands would accomplish this task?

Options

  • Agrep -i auto /etc/systemd/journald.conf && systemctl restart systemd-journald.service
  • Bcat /etc/systemd/journald.conf | awk '(print $1,$3)'
  • Csed -i 's/auto/persistent/g' /etc/systemd/journald.conf && sed -i 'persistent/s/^#//q'
  • Djournalctl --list-boots && systemctl restart systemd-journald.service

How the community answered

(34 responses)
  • A
    3% (1)
  • B
    9% (3)
  • C
    74% (25)
  • D
    15% (5)

Why each option

To ensure systemd journal logs persist across system reboots, the `Storage` parameter in `/etc/systemd/journald.conf` must be set to `persistent` and the `systemd-journald` service restarted.

Agrep -i auto /etc/systemd/journald.conf && systemctl restart systemd-journald.service

`grep -i auto /etc/systemd/journald.conf` only searches for the string 'auto' and does not modify the configuration for persistence.

Bcat /etc/systemd/journald.conf | awk '(print $1,$3)'

`cat /etc/systemd/journald.conf | awk '(print $1,$3)'` merely displays parts of the configuration file and does not implement any changes to ensure log persistence.

Csed -i 's/auto/persistent/g' /etc/systemd/journald.conf && sed -i 'persistent/s/^#//q'Correct

The `sed -i 's/auto/persistent/g' /etc/systemd/journald.conf` command modifies the `journald.conf` file to change the `Storage` setting from `auto` to `persistent`, which configures systemd to store logs permanently on disk. The subsequent `sed -i 'persistent/s/^#//q'` command ensures that the `Storage=persistent` line is uncommented if it was previously commented out, making the setting active; restarting `systemd-journald.service` applies these changes.

Djournalctl --list-boots && systemctl restart systemd-journald.service

`journalctl --list-boots` displays boot journal entries, which would be empty or incomplete if persistence is not configured, and restarting the service alone without configuration changes will not enable persistence.

Concept tested: systemd journal persistence configuration

Source: https://www.freedesktop.org/software/systemd/man/journald.conf.html

Topics

#systemd-journald#Log Persistence#Configuration Management#sed command

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice