Master Real-Time Log Monitoring on Linux with tail, multitail, lnav & less
This guide explains how to monitor Linux log files in real time using commands such as tail (with -f, -F, and -n options), tailf, multitail, lnav, and less, including installation instructions for various distributions and examples for Apache logs.
1. tail Command – Monitor Logs in Real Time
As mentioned, tail is the most common way to display logs in real time. It has two variants:
Using -f option
<code>$ sudo tail -f /var/log/apache2/access.log</code>Using tailf (built‑in -f)
<code>$ sudo tailf /var/log/apache2/access.log</code>For rotated logs, use
-Fto follow new files:
<code>$ sudo tail -F /var/log/apache2/access.log</code>To view only the last two lines in real‑time, combine
-nand
-f:
<code>$ sudo tail -n2 -f /var/log/apache2/access.log</code>2. Multitail Command – Monitor Multiple Log Files in Real Time
Multitail can monitor several logs simultaneously and allows scrolling.
Install Multitail:
<code>$ sudo apt install multitail [On Debian & Ubuntu]
$ sudo yum install multitail [On RedHat & CentOS]
$ sudo dnf install multitail [On Fedora 22+ version]</code>Example to display two logs:
<code>$ sudo multitail /var/log/apache2/access.log /var/log/apache2/error.log</code>3. lnav Command – Monitor Multiple Log Files in Real Time
lnav is another tool for real‑time multi‑file monitoring.
Install lnav:
<code>$ sudo apt install lnav [On Debian & Ubuntu]
$ sudo yum install lnav [On RedHat & CentOS]
$ sudo dnf install lnav [On Fedora 22+ version]</code>Example usage:
<code>$ sudo lnav /var/log/apache2/access.log /var/log/apache2/error.log</code>4. less Command – Display Real Time Output of Log Files
You can also use
lessand press Shift+F (or start with
+F) to follow a file:
<code>sudo less +F /var/log/apache2/access.log</code>Additional articles on log monitoring and management are listed:
Manage Files Effectively using head, tail and cat Commands in Linux
How to Setup and Manage Log Rotation Using Logrotate in Linux
Petiti – An Open Source Log Analysis Tool for Linux SysAdmins
How to Query Audit Logs Using ‘ausearch’ Tool on CentOS/RHEL
Manage Log Messages Under Systemd Using Journalctl {Comprehensive Guide}
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.