To see the last 20 lines of a log:
tail -n 20 /var/log/syslog
To follow as new lines are written:
tail -f /var/log/syslog
You can combine with grep to filter:
tail -f /var/log/syslog | grep error
Published 2025-10-20 14:24:39 UTC
How to monitor logs in real-time with tail
The `tail` command prints the last lines of a file and can follow updates in real-time.
To see the last 20 lines of a log:
tail -n 20 /var/log/syslog
To follow as new lines are written:
tail -f /var/log/syslog
You can combine with grep to filter:
tail -f /var/log/syslog | grep error