journalctl: how to prevent text from truncating in terminal
From the journalctl
manpage:
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.
If you don't want to constantly be using the left and right arrow keys, simply pipe it directly to less
:
$ journalctl -xn | less
This will wrap lines that are too long for your terminal (the default behavior of less
, which journalctl
overrides).
Or, of course, if you don't mind possibly having to use your terminal's scrollback, you could use no pager at all:
$ journalctl -xn --no-pager
I also do:
journalctl -xn | less
But you can also set the SYSTEMD_LESS
environment variable:
SYSTEMD_LESS=FRXMK journalctl -xn
# Or even
# SYSTEMD_LESS="" journalctl -xn
# The environment variable needs to be there, but can be the empty string
I got that from: [systemd-devel] [PATCH] pager: wrap long lines by default
Set it in your .bashrc and be done with it! :-)
That systemd
needs to setup less
specially and doesn't just honor the less defaults and the LESS
environment seems a little arrogant to me, but hey, this works...
If the program already uses less
(if not, pipe the output to it), you can enable/disable line wrapping by typing -S
(in less
), This works for other less
options as well.