$ run as a normal user# run as root (or with sudo)
The quick answer
journalctl -u nginx -n 50 --no-pager
journalctl -u nginx -f
journalctl -u nginx --since "1 hour ago" -p warning
journalctl -xeu nginx-u = one unit, -n 50 = last 50 lines, -f = follow live, -p warning = warnings and worse, -xe = jump to the end with explanations.
Step by step
- Find the exact unit name:
systemctl status already shows the last 10 log lines — often enough.
- Choose the time window:
journalctl -u nginx --since today
journalctl -u nginx --since "2026-11-17 09:00" --until "2026-11-17 09:30"
journalctl -u nginx -b
journalctl -u nginx -b -1-b = since this boot; -b -1 = the boot before (great after a crash and reboot — needs a persistent journal, see below).
- Only what matters:
journalctl -p err -b
journalctl -u sshd | grep -i "failed password"
journalctl -u myapp -o json-pretty -n 1
journalctl _PID=1432- Apps with their own log files (web servers, databases, Java apps):
ls -lt /var/log | head
tail -F /var/log/nginx/error.log
tail -n 200 /var/log/nginx/access.log | awk '$9 >= 500'
grep -i error /var/log/mariadb/mariadb.log | tailtail -F (capital F) keeps following when the file is rotated.
- Containers and Kubernetes log to stdout:
docker logs --tail 100 -f web
kubectl logs deploy/shop-api --tail 100 -f
kubectl logs shop-api-7c9d8-abcde --previous- Keep logs after a reboot (if
-b -1shows nothing):
mkdir -p /var/log/journal
systemctl restart systemd-journald
journalctl --list-boots | tail -3Check that it worked
You see the lines from the time the problem happened, and you can follow new ones live while you test:
journalctl -u nginx -f &
curl -s -o /dev/null http://127.0.0.1/
journalctl --disk-usageCommon problems
| Problem | Cause | Fix |
|---|---|---|
-- No entries -- | Wrong unit name or time window, or the app logs to a file. | systemctl status for the name; check /var/log/APP/. |
| Only some lines as a normal user | No permission for system logs. | Use sudo, or add the user to systemd-journal (or adm on Ubuntu). |
| Nothing from before the reboot | The journal is not persistent. | Create /var/log/journal and restart journald. |
| The journal uses many GB | No size limit. | journalctl --vacuum-size=500M; set SystemMaxUse= in /etc/systemd/journald.conf. |
| Container logs fill the disk | No log rotation for containers. | Docker daemon.json log max-size/max-file. |
| The error is not clear | Short message only. | journalctl -xeu UNIT for context; raise the app's log level for a while. |
Go further
- Command pages: journalctl, tail, grep, systemctl.
- Next how-tos: Start, stop, restart and enable a service, See the logs of a container, Keep the journal after reboot, Rotate log files with logrotate.
- Central logs for all servers: Grafana Loki, Fluent Bit.
- Learn it for RHCSA: RHCSA — Logs. Practise: Lab: logs.
1How do you see the log of a service from the boot before the last crash?
journalctl -u NAME -b -1 — with a persistent journal (/var/log/journal).