LPIC-1 Exam 101 Practice Questions

Linux Professional Institute LPIC-1 Exam 101 (101-500) exam preparation

LPIC-1 Exam 101 practice questions in English: 180 questions with explanations. The mock exam has 60 questions and 90 minutes.

LPIC-1 Exam 101 free question 2 / 10 · Domain 1: System Architecture

On a systemd machine, you want to read from the journal only the messages recorded during the previous boot, not the current one. Which command do you run?

  1. journalctl -b 0
  2. journalctl -b 1
  3. journalctl -b -1
  4. journalctl -b all
Show the answer and explanation

Answer: C

Why this is correct
The -b (--boot) option of journalctl(1) restricts the output to the messages of a particular boot. When a number is given without a boot ID, a value of 0 or below counts from the end of the journal: -0 is the last boot and -1 is the one before it. The boot that is running now is the last boot in the journal, so the previous boot is addressed as -b -1.

Why the other options are wrong
"journalctl -b 1" … A positive number counts from the beginning of the journal, oldest first. 1 refers to the oldest boot kept in the journal, not the previous one. Forgetting the sign would show you a boot from an entirely different day.
"journalctl -b 0" … 0 counts from the end and means the last boot, which is the current boot. The result is the same as giving -b alone.
"journalctl -b all" … all is a special value that cancels an earlier -b filter, so the messages of every boot are shown.

Listing the boots
journalctl --list-boots lists the boots that remain in the journal, with the current one as 0 and earlier ones as -1, -2, and so on. Messages of earlier boots are readable if the journal is stored persistently, that is, under /var/log/journal/ (see --flush in journalctl(1)). For a machine that no longer boots, you can start from other media and point -D at that directory to read it.

Go to the LPIC-1 Exam 101 practice app (10 free questions; purchase unlocks all questions)

See the full practice set