Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Commands You Will Use Most

sudo journalctl -u nginx
sudo journalctl -u nginx -f
sudo journalctl -u nginx --since "1 hour ago"
sudo journalctl -p err -b

These show one service's log, follow it live, limit it to the last hour, and list errors since the last boot. Without filters, journalctl shows the whole journal from the oldest entry, in a pager: use the arrow keys, / to search, G to jump to the end, and q to quit.

Who Can Read the Journal

Without sudo, a normal user sees only their own entries, and only when the journal is stored on disk. Root and members of the systemd-journal, adm, and wheel groups can read the whole journal. Run id to see your groups.

Filter by Service

-u takes a unit name; the .service suffix is optional. Use it several times to see two services together, in time order:

sudo journalctl -u nginx -u mariadb --since today

To find the right unit name, see how to list services with systemctl.

Follow, Limit, and Reverse

OptionWhat it does
-fFollows new entries; Ctrl+C stops
-n 50Shows the last 50 lines
-rNewest entries first
-eJumps to the end in the pager
--no-pagerPrints straight to the terminal
-o catMessage text only

journalctl -f works like tail -f on a file; see the tail command for logs that are still plain files.

Filter by Boot

sudo journalctl -b
sudo journalctl -b -1
sudo journalctl --list-boots

-b is the current boot and -b -1 the one before. That is where you find out why a server rebooted or failed, but only if the journal is stored on disk, as explained below.

Filter by Priority

-p err shows errors and everything more severe. The levels, from most to least severe, are emerg, alert, crit, err, warning, notice, info, and debug. A range also works: -p warning..err.

Filter by Time

sudo journalctl --since "2026-11-28 09:00" --until "2026-11-28 10:30"
sudo journalctl --since yesterday --until today
sudo journalctl -u ssh --since "30 min ago"

Times are in the server's time zone. Combine time with -u and -p to cut a large journal down to the lines that matter.

Kernel Messages

sudo journalctl -k
sudo journalctl -k -b -1

-k shows only kernel messages of the current boot, the same as dmesg, but with reliable timestamps; with -b -1 and a journal on disk, it covers earlier boots too.

Journal Size and Cleanup

sudo journalctl --disk-usage

Vacuuming deletes log history for good. Copy anything you may need first, for example with journalctl --since ... > file.txt, then keep either a time span or a size:

sudo journalctl --vacuum-time=2weeks
sudo journalctl --vacuum-size=500M

Vacuuming removes only archived journal files, not the active one, so the result can be a little above the limit.

Keep the Journal After a Reboot

The default depends on the systemd version. With Storage=auto, the default in older versions such as the one in Ubuntu 24.04, the journal is written to /var/log/journal if that directory exists, and to memory under /run/log/journal if it does not; the newest systemd releases default to persistent. Run ls /var/log/journal to see which applies. To make it persistent on any version and cap its size, create a drop-in file such as /etc/systemd/journald.conf.d/persistent.conf:

[Journal]
Storage=persistent
SystemMaxUse=500M

Then apply it with sudo systemctl restart systemd-journald. Where the remaining log files live is in Linux log files.

Was this answer helpful?
Loading...