Read logs with journalctl
journalctl reads the logs that systemd collects from the system and from every service, in one searchable place.
- Updated Nov 27, 2026
- Markdown
Read, follow and filter system and service logs with journalctl.
- A systemd Linux server with sudo access
A service stops answering. To read its logs on a systemd server, run sudo journalctl -u servicename -n 50. You could guess, or you could read what it said just before it failed: the error, the exit code, the line that tells you which file it could not open. On a systemd server that history is in the journal. Learning a handful of journalctl options turns a vague failure into a specific message.
How it works#
systemd starts and supervises services. It captures everything a service prints to its standard output and standard error, plus messages sent through the system log interface, and stores them in a binary journal. The journal records the time, the unit (service) name, a priority level and the message. Because it is indexed, journalctl can filter fast by unit, time, boot or priority.
Messages carry a priority from emerg and alert through crit, err, warning, notice and info to debug. Filtering with -p err shows err and anything more severe.
The journal may be volatile, kept in memory under /run/log/journal and lost at reboot, or persistent, kept in /var/log/journal. On Ubuntu it is normally persistent. Its size is capped by system settings, so very old entries are removed automatically.
Programs that write their own files, such as nginx, still write to /var/log/nginx/. The journal covers systemd services and the system itself, and you read other logs with tail and less.
A worked example: your app service demo fails after a deploy. You run sudo journalctl -u demo -n 30 --no-pager. The last lines say it could not open a config file. You fix the path, run sudo systemctl restart demo, then sudo journalctl -u demo -f and watch it start cleanly. You read, fix, restart and watch, using the same tool each time.
Step 1: Read recent logs#
sudo journalctl -n 50-n 50 shows the last 50 lines. Without it you get every stored entry, oldest first, in a pager.
What you should see: lines that start with a date and time, the host name, the program name with its process ID and a message.
Step 2: Show logs for one service#
sudo journalctl -u ssh-u filters by unit name. On Ubuntu the SSH service is ssh. On other systems it may be sshd. Add -e to jump to the end.
What you should see: only lines from that service, such as login messages. Use -r to show the newest first.
Step 3: Follow logs live#
sudo journalctl -u ssh -fNew lines appear as they happen. Press Ctrl+C to stop.
What you should see: the last few lines, then the command waits. Log in from another terminal and a new line appears.
Step 4: Filter by time and level#
sudo journalctl --since "1 hour ago"
sudo journalctl -p err -b
sudo journalctl -u ssh --since "2026-11-27 09:00" --until "2026-11-27 10:00"--since and --until limit the time range. -p err shows only errors and worse, and -b limits the output to the current boot.
What you should see: a shorter list, or -- No entries -- if nothing matches.
Step 5: Check how much space logs use#
journalctl --disk-usageWhat you should see: a line such as Archived and active journals take up followed by a size. Logs can grow over time (the same worry as in check disk, memory and CPU usage). Trimming them is a deliberate step, so read the journalctl manual before you run --vacuum-size or --vacuum-time, which delete old entries.
Check it worked#
After step 1 you should see lines that start with a date, the host name, the program name and a message. After step 3 the command should wait and print new lines as they arrive, for example when you log in again with SSH. For a plain text version that works in scripts, add --no-pager and -o short-iso, which prints ISO timestamps.
Edge cases and gotchas#
- Times are shown in the server’s time zone. If the server runs UTC and you think in local time, your
--sincewindows will look off. Checktimedatectl. Add--utcto be explicit. - The journal can be empty after a reboot. If the journal is only in memory, the logs before the reboot are gone. Create
/var/log/journaland restartsystemd-journald, or setStorage=persistentin the journald config, if you want to keep them. - Lines may be cut off. The pager does not wrap long lines. Use
--no-pageror press the right arrow, and add-o catto print only the message. - A service’s own file logs are separate. If a program logs to
/var/log/app.log, journalctl will not show those lines unless the service also writes to the console. - Docker container logs are not in the journal by default. (See read container logs.) Use
docker logsordocker compose logs. Docker’s own daemon messages are under-u docker. - Kernel messages have their own view.
journalctl -kshows the kernel ring buffer, which is where out-of-memory kills and disk errors appear. -umatches the unit name, not the program. The service for Docker isdocker, and for SSH on Ubuntu it isssh. Check withsystemctl list-units --type=service.- Permissions hide other users logs. A normal user sees only its own entries unless in the
systemd-journalgroup.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
No journal files were found. | Journal not stored on disk or you lack access | Try sudo, or check the persistent storage setting |
-- No entries -- | Filters are too narrow | Widen the time range or check the unit name |
systemctl status nginx says Unit nginx.service could not be found. and journalctl -u nginx shows no entries | Wrong service name or not installed | List with systemctl list-units --type=service |
| Hint that you are not seeing all messages | Your user is not in the right group | Use sudo or add yourself to systemd-journal |
Output ends with lines 1-23 and waits | You are in the pager | Press q |
| Logs stop at an old date | The journal was rotated or vacuumed | Check journalctl --disk-usage and the size limit |
| Output too wide to read | Long lines in the pager | Add --no-pager or -o cat |
| Cannot find old logs after reboot | Journal is volatile | Make it persistent, see the gotchas above |
Real-world scenario#
Nina deploys an update and the site returns errors. The service is called webapp. She runs sudo systemctl status webapp and sees activating (auto-restart), so it keeps crashing. She runs sudo journalctl -u webapp -n 40 --no-pager and finds Error: EADDRINUSE, which means another process holds the port.
She checks with sudo ss -ltnp and finds an old copy of the app still running. She stops it, restarts the service, and journalctl -u webapp -f shows a clean start.
Without the journal she would have guessed. With it she read the answer in the first screen.
Quick reference#
| Task | Command |
|---|---|
| Last 50 lines | sudo journalctl -n 50 |
| One service | sudo journalctl -u ssh |
| Follow live | sudo journalctl -u ssh -f |
| Since a time | sudo journalctl --since "1 hour ago" |
| Errors this boot | sudo journalctl -p err -b |
| Previous boot | sudo journalctl -b -1 |
| Kernel messages | sudo journalctl -k |
| Space used | journalctl --disk-usage |
Security and safety notes#
--vacuum-sizeand--vacuum-timedelete log history for good. Do not run them while you are still investigating a problem.- Logs can contain passwords, tokens or personal data. Check before you paste them into a public forum.
Related lessons#
- Run a service with systemd: where service logs come from
- Read container logs: the Docker side
- Limit Docker log size: keep logs from growing without end
- Fix 502 Bad Gateway: logs are the first stop
Next#
Check what you learned
Frequently asked questions
Why do I get no entries or a permission message?
Normal users may only see their own logs. Use sudo, or add your user to the systemd-journal group.
How do I leave the log view?
Press q. The output opens in a pager, so you can also scroll with the arrow keys and search with a slash.
Do logs survive a reboot?
Only if the journal is stored on disk. On some systems it is kept in memory and lost at reboot. Check for the /var/log/journal folder, and ask for the previous boot with journalctl -b -1.
Where are the logs of my Docker containers?
Docker keeps its own container logs, read with docker logs. The journal shows the Docker service itself. See the container logs lesson.
Sources
Keep going: guides and tutorials
- Install a Self-Hosted PaaS on Your Own Server in Five Minutes One installer download, one setup token, one sample app. The full Levelrail install on a fresh Linux server, with the checks and the fixes.
- Manage Secrets Self-Hosted: Env Vars and Master Key Rotation Set env vars and encrypted secrets on a self-hosted server, apply changes safely, and rotate the master key with no downtime without locking yourself out.