How to read Linux server logs
Where Linux keeps its logs, the commands to actually read them, and how to filter thousands of lines down to the one that matters.
When something goes wrong on a VPS, the log files almost always already contain the answer — the job is filtering years of routine, uneventful lines down to the handful that explain what just happened. This guide covers where the logs live and the commands to search them properly, rather than scrolling.
journalctl: the systemd journal
On any modern distribution using systemd — which is all of Ubuntu, Debian, RHEL, Rocky Linux and AlmaLinux today — most system and service logs go into a single binary journal, read with journalctl.
Logs for one specific service:
journalctl -u nginx
Follow a service's logs live, exactly like tail -f:
journalctl -u nginx -f
Restrict to a time window, which is usually far more useful than scrolling through everything:
journalctl -u nginx --since "1 hour ago"
journalctl -u nginx --since "2026-08-20" --until "2026-08-21"
Only the most recent boot's logs:
journalctl -b
Only errors and more severe entries, across every service:
journalctl -p err
journalctl -xe is worth knowing specifically: it jumps to the end of the journal and adds extra explanatory context where systemd has it, and it is the command most often suggested after a service fails to start.
Traditional log files under /var/log
Not everything goes through the journal. Web servers, in particular, still write their own plain-text log files:
| Log | Location |
|---|---|
| System log (Debian/Ubuntu) | /var/log/syslog |
| System log (RHEL family) | /var/log/messages |
| Authentication attempts | /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (RHEL family) |
| Nginx access / error | /var/log/nginx/access.log, /var/log/nginx/error.log |
| Apache access / error | /var/log/apache2/ (Debian/Ubuntu) or /var/log/httpd/ (RHEL family) |
| MariaDB/MySQL error log | /var/log/mysql/error.log or /var/log/mariadb/mariadb.log |
| Cron | /var/log/cron (RHEL family) or included in syslog (Debian/Ubuntu) |
Read a plain-text log the same way you would any file. tail shows the end of it, which is usually what you want since logs grow downward:
tail -100 /var/log/nginx/error.log
Follow it live as new lines are written, most useful while reproducing a problem:
tail -f /var/log/nginx/error.log
Searching for what you actually need
Rather than reading top to bottom, search for the thing that matters:
grep -i "error" /var/log/nginx/error.log
grep -i "failed password" /var/log/auth.log
journalctl -u nginx | grep -i "error"
-i makes the search case-insensitive, which matters since log formats are not consistent about capitalisation. Combine with -C 3 to show three lines of surrounding context, since a single matching line is often meaningless without what came immediately before and after it:
grep -i -C 3 "segfault" /var/log/syslog
Understanding log severity levels
Most services log at graded severities, from least to most serious: debug, info, notice, warning, error, critical, alert, emergency. When you are hunting for a fault, filter to error and above first — journalctl -p err — and only widen the search if that comes up empty. warning-level noise in particular is often routine and can drown out the line you actually need.
Keeping logs from filling the disk
Logs that are never rotated or trimmed will eventually fill a filesystem, which is a self-inflicted outage entirely avoidable with basic housekeeping. Most distributions ship logrotate already configured for the common services, but the systemd journal is managed separately and is worth checking directly:
journalctl --disk-usage
If it has grown larger than you want, cap it:
sudo journalctl --vacuum-time=7d
sudo journalctl --vacuum-size=500M
The first keeps only the last seven days regardless of size; the second keeps the journal under a fixed size regardless of age. Either is safe to run at any time — it only removes journal entries, not the running services that produced them.
Checking which log files are actually large
Before assuming a disk-space problem is caused by application data, check whether logs themselves are the culprit — an application logging at excessive verbosity, or a rotation policy that never took effect, can quietly consume gigabytes over months:
du -sh /var/log/* 2>/dev/null | sort -rh | head -10
If one specific log has grown unreasonably large, check that logrotate actually has a configuration covering it — most packages install their own rule under /etc/logrotate.d/, but a manually installed application sometimes does not, and its log then grows unchecked until something else notices.
Whatever the symptom — a service that will not start, a site returning an error, a login that is unexpectedly rejected — the relevant log almost always states the reason in plain language, in the last few lines. Read those before searching for the symptom online; a search for the exact error message from your own log is usually faster than guessing at the cause.
Once you can find the relevant log line, the next skill is knowing what to do about the service itself — see restarting services safely, and setting up Fail2ban if what you are seeing in auth.log or secure is repeated failed logins.
Related reading
The commands that show you exactly what is consuming CPU, memory and disk on a VPS, and how to identify the process responsible.
How to restart services safelyThe right systemctl commands to restart or reload a Linux service, and why checking its status straight afterwards is not optional.
How to set up Fail2banInstalling Fail2ban to automatically block repeated failed logins, configured safely so you do not end up banning yourself.
How much RAM does my VPS need?It depends what is running, but free -h on an existing server and a look at what each extra service costs gets you a real answer fast.