After viewing logs with journalctl, how do I exit the screen that says "lines 1-2/2 (END)"?

8,179

Solution 1

A smooth way to end that command is to hit q (for quit). It looks like it is viewed with the viewer less.

You can quit from this command and several other text mode programs with q. In this case and several other cases you can also quit with the ctrl C interrupt, but it is 'more brutal'.

Solution 2

Read man journalctl. In the Description section, it says:

The output is paged through less by default, and long lines are "truncated" to screen width. The hidden part can be viewed by using the left-arrow and right-arrow keys. Paging can be disabled; see the --no-pager option and the "Environment" section below.

So, you should read man less to learn about this useful tool.

One of the things you can learn from man less is:

   q or Q or :q or :Q or ZZ
          Exits less.

Solution 3

As mentioned in the other answers you can hit q to exit the less pager.

Assuming that the output is short, another option is to directly require the command not to use the pager. In the case of journalctl this is done with the option --no-pager:

journalctl -p err -b --no-pager
Share:
8,179

Related videos on Youtube

Skalman65
Author by

Skalman65

Updated on September 18, 2022

Comments

  • Skalman65
    Skalman65 over 1 year

    When you use the command journalctl -p err -b for example, you get an answer that ends with "END". What command do I use to end this and get the opportunity to enter the next command without having to close the window and open a new one?

    erik@server ~ $ journalctl -p err -b
    -- Logs begin at sön 2019-09-22 20:17:42 CEST, end at sön 2019-09-22 20:20:01 CE
    sep 22 20:17:51 server iscsid[1289]: iSCSI daemon with pid=1290 started!
    lines 1-2/2 (END)
    

    terminal screenshot

  • wjandrea
    wjandrea over 4 years
    It seems like it's actually not using less itself but a less-related library, cause pidof less outputs nothing while it's running, and I tried to disable the paging with LESS=F journalctl -p err -b but it didn't work. Compare to git where both of those work.
  • Eliah Kagan
    Eliah Kagan over 4 years
    It's using less. With $SYSTEMD_PAGER and $PAGER unset, journalctl tries some commands, including (as journalctl(1) says) less. But it tries pager first. In Debian and Ubuntu, /usr/bin/pager is a symlink to /etc/alternatives/pager, which is a symlink to /bin/less (which users rarely change). So pidof less doesn't work but pidof pager does. journalctl resets $LESS, by default to FRSXMK, but you can set $SYSTEMD_LESS. FRSXMK contains F but the F option only disables paging when neither vertical nor horizontal scrolling is needed; see the S option. @wjandrea
  • Melebius
    Melebius over 4 years
    Worth noting that man also runs less usually, so you’ll need q to exit it, too!
  • interfect
    interfect over 4 years
    Do they document why they page 2 lines of output? Git for example is clever enough to tell when it is only going to show you less than a screen of text and not invoke a superfluous pager.
  • pt314
    pt314 over 4 years
    @interfect Per Eliah Kagan's earlier comment on another answer, it would indeed just show the output without paging if it would fit without scrolling, but line wrapping is turned off as well (to avoid ambiguity I guess), and although the example output is not taller than the output terminal, it is wider.