brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: SYSTEMD_LESS changes how the journalctl pager behaves

Journalctl
~/tips/tip-journalctl-systemd-less

SYSTEMD_LESS=FRXMK journalctl -u nginx

Make the journalctl pager wrap long lines instead of cutting them off at the screen edge.

journalctl starts less with its own set of options, and one of them chops long lines at the edge of the screen. I’d rather have them wrapped.

The default flags are FRSXMK. The S is the one that cuts long lines, so drop it:

SYSTEMD_LESS=FRXMK journalctl -u nginx

Long nginx or PHP error lines now wrap over several screen lines, so you can read them without scrolling sideways. The other letters are worth keeping: F quits right away when the output fits on one screen, R keeps the colors, X leaves the text on screen after you quit, M gives a more detailed prompt and K lets Ctrl+C quit the pager.

To make it stick, put it in your shell profile:

export SYSTEMD_LESS=FRXMK

It applies to every systemd tool that uses a pager, so systemctl status and systemctl cat wrap too. Inside the pager you can still toggle chopping per session by typing -S and Enter.

Setting SYSTEMD_LESS replaces the defaults completely; it does not add to them. If you write just SYSTEMD_LESS=X you lose the colors and the quit on Ctrl+C, so start from the full default string and remove what you dislike.

Further reading: journalctl man page (environment), systemd environment variables

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys All Journalctl tips (81) All topics

Link