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: the systemd-journal group lets you read every log without sudo

Systemd
~/tips/tip-journalctl-systemd-journal-group

sudo usermod -aG systemd-journal $USER

Read the system journal as your normal user, without typing sudo every time.

Typing sudo journalctl every single time gets old. Without sudo, though, you only see your own user’s journal, plus a hint that you’re missing the rest.

sudo usermod -aG systemd-journal $USER

Log out and back in, because a new group only counts from your next login, and plain journalctl now shows the system journal and the journals of other users too. The journalctl man page names the groups that can read all journal files: systemd-journal, adm and wheel. I’d pick systemd-journal. The man page points out that the other two traditionally come with additional privileges set by the distribution, and wheel is often the group that may run admin tasks.

A quick check after logging in again:

id -nG
journalctl -u ssh -n 20

If systemd-journal is in the list and the second command shows the SSH service’s lines without complaining, it worked.

The caveat: reading the journal isn’t harmless. Logs can contain IP addresses, user names, the commands people ran with sudo and now and then a token an app printed by accident. Only add accounts you’d trust with all of that. And it’s read access only: cleaning up old journal files or changing journald settings still needs root.

Further reading: journalctl(1) man page

More Systemd tips [Service] sudo mkdir -p /etc/systemd/system/service.d [Service] printf 'hunter2' | sudo systemd-creds encrypt --name=dbpass – dbpass.cred systemd-analyze timespan 1h30min All Systemd tips (88) All topics

Link