Most current Linux VPS images run systemd, and systemd writes its logs to the journal. journalctl is the tool you use to read that journal: live output from a service, errors from the current boot, or what happened just before a crash. It is more useful than scrolling a pile of text files, because you can filter by unit, time, priority and boot in one command.
This is a practical how-to for a Linux VPS. It is not a full systemd internals guide, and it does not replace application logs that a process still writes to its own file. Start here when SSH, Nginx, a database, or a failed reboot has left you looking for the first real error.
What the journal stores, and where
The journal is a structured log. Each entry has a timestamp, a systemd unit, a priority, and often the process that wrote it. On many cloud images the journal lives only in memory, so a reboot wipes it. That is a problem when you are trying to learn why the box did not come back cleanly.
Check where the data is and how much disk it uses:
journalctl --disk-usage
ls -ld /var/log/journal
systemd-analyze cat-config systemd/journald.conf | grep -E 'Storage|SystemMaxUse|RuntimeMaxUse'
If /var/log/journal is missing and Storage is set to auto or volatile, logs will not survive a reboot. To keep them, set Storage=persistent in /etc/systemd/journald.conf, create the directory, and restart the journal:
sudo mkdir -p /var/log/journal
sudo systemd-tmpfiles --create --prefix /var/log/journal
# set Storage=persistent in /etc/systemd/journald.conf, then:
sudo systemctl restart systemd-journald
Persistent logs can fill a small disk. Cap them, and vacuum when needed. A full root filesystem is a different failure, covered in the disk full VPS guide, but the journal is often one of the first directories worth checking:
sudo journalctl --vacuum-size=200M
# or keep only recent history
sudo journalctl --vacuum-time=14d
Read the current boot, then narrow it
The first useful view is “what went wrong on this boot,” not the entire history:
journalctl -b -p err
journalctl -xe
journalctl --list-boots
-b limits the view to the current boot. -b -1 is the previous boot, which is what you want after a crash or a forced restart, assuming the journal is persistent. -p err keeps error and worse (error, critical, alert, emergency). -xe jumps toward the end and explains a few common unit errors. --list-boots shows the boot IDs you can pass to -b.
If you are not root and see nothing, your user may lack access. On Debian and Ubuntu, membership in adm or systemd-journal is usually enough. Do not chmod the journal files by hand.
Filter by service, time and priority
Once you know which unit failed, stay on that unit. Guessing from a mixed stream wastes time:
journalctl -u ssh -n 50
journalctl -u ssh -n 50 --no-pager
journalctl -u nginx -f
journalctl -u mariadb --since "1 hour ago"
journalctl -u postfix --since "2026-11-18 09:00" --until "2026-11-18 10:00"
-u is the systemd unit name, usually the same name you pass to systemctl. -n caps the number of lines. -f follows new entries, like tail -f. Time filters accept “1 hour ago,” “today,” or an explicit timestamp.
You can combine units and also match a field or a syslog identifier:
journalctl -u nginx -u php-fpm -p warning --since "20 min ago"
journalctl /usr/sbin/sshd
journalctl SYSLOG_IDENTIFIER=sudo
When SSH itself is the problem, the journal is often clearer than a hanging client. The SSH connection refused guide walks through the listening socket and firewall checks; use journalctl -u ssh -u sshd -b next to those checks so you can see whether sshd refused the key, failed to start, or never ran at all. Unit names vary: Debian and Ubuntu typically use ssh.service, many other images use sshd.service.
Find the error after a crash or a failed start
Work from the failure backward, not from boot forward. If a site returns 502, start with the proxy and the upstream, then widen the window:
systemctl is-active nginx php-fpm
journalctl -u nginx -u php-fpm -p err --since "15 min ago"
# previous boot, if the box just rebooted
journalctl -b -1 -p err
The 502 Bad Gateway guide covers proxy timeouts and a dead upstream. The journal tells you whether Nginx reloaded a bad config, whether PHP-FPM exited, or whether the kernel OOM-killed a worker. For a database that stopped accepting clients, the same pattern applies with the database unit, alongside the checks in the MySQL connection errors guide.
Kernel and hardware messages sit in the journal too. After a sudden reboot, look at the previous boot for OOM, filesystem errors, or a kernel panic residue:
journalctl -k -b -1
journalctl -b -1 -g "Out of memory|oom-kill|EXT4-fs error|I/O error"
-k is kernel messages. -g is a case-insensitive grep on the message text. If the previous boot is empty, the journal was probably volatile, or the host hard-reset the VM before systemd flushed anything.
A high load or steal-time incident is easier to explain when you can line the timestamps up with service errors. The CPU steal time guide and the Linux monitoring guide help you watch the metrics; journalctl --since around the same window tells you whether a service crash, a backup job, or a kernel event landed at the same moment.
Keep journalctl usable day to day
A few habits save time on a VPS you actually operate:
- Prefer
-uand a time window over dumping the whole journal. - Use
--no-pagerin scripts and in copy-paste sessions where the pager gets in the way. - Use
-o short-isowhen you need unambiguous timestamps, or-o json-prettywhen you want the fields. - Leave
Storage=persistenton, with a size cap that fits the disk. - Do not treat the journal as a backup. If you need long retention, ship logs off the box.
journalctl -u nginx -o short-iso --since "1 hour ago" --no-pager
# show extra fields for one entry
journalctl -u ssh -n 1 -o verbose
Application logs still matter. A process can write to /var/log and to the journal, or only to one of them. If journalctl -u is quiet but the service is clearly failing, look at the unit’s own log path and at systemctl status for the last few lines. Hardening steps such as firewall rules and failed-login limits, described in the VPS security guide, also show up in the journal when a rule or a service fails to apply.
Frequently asked questions
Why is journalctl empty after a reboot?
The journal was almost certainly volatile. Enable persistent storage, confirm /var/log/journal exists, and reboot once to verify the previous boot appears in journalctl --list-boots.
What is the difference between journalctl and /var/log/syslog?
On systemd images, the journal is the primary source. Some distributions still write a text syslog file as well. Use journalctl for unit and boot filters; use the text file if an older tool still expects it. Do not assume both contain the same lines.
Can I delete the journal to free disk space?
Yes, but vacuum it rather than rm the files under /var/log/journal. journalctl --vacuum-size=200M or --vacuum-time=14d is the supported way. If the disk is already full, free some space first so those commands can run.
Why do I get a permission denied error?
Your user is not allowed to read the journal. Use sudo, or add the account to adm or systemd-journal and start a new session. Do not loosen permissions on the journal directories.
Does journalctl show logs from Docker or other containers?
Only if those processes log to the journal, or if you query the units that wrap them. Many containers log only to the container runtime. Check journalctl -u docker or the unit for the container, then the runtime’s own logs if that is quiet.