Master Real-Time Log Monitoring on Linux with Tail, Multitail, Lnav & Less
Learn how to instantly watch and follow log files on Linux using tools like tail, tailf, tail -F, multitail, lnav, and less, with installation tips, command options, and practical examples for both single and multiple log streams.
Real‑time Log Viewing on Linux
Linux provides several utilities to display log file contents as they grow, with tail being the most common.
1. tail Command – Monitor Logs in Real Time
The basic
-foption follows a file:
<code>$ sudo tail -f /var/log/apache2/access.log</code>Alternatively, the
tailfcommand has
-fbuilt‑in, so you can simply run:
<code>$ sudo tailf /var/log/apache2/access.log</code>For rotating logs, use
-Fto follow a file by name even after it is recreated:
<code>$ sudo tail -F /var/log/apache2/access.log</code>If you only need 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
Install Multitail on Debian/Ubuntu, RedHat/CentOS, or Fedora:
<code>$ sudo apt install multitail [On Debian & Ubuntu]</code>
<code>$ sudo yum install multitail [On RedHat & CentOS]</code>
<code>$ sudo dnf install multitail [On Fedora 22+]</code>Display two logs side by side:
<code>$ sudo multitail /var/log/apache2/access.log /var/log/apache2/error.log</code>3. lnav Command – Monitor Multiple Log Files
Install Lnav similarly:
<code>$ sudo apt install lnav [On Debian & Ubuntu]</code>
<code>$ sudo yum install lnav [On RedHat & CentOS]</code>
<code>$ sudo dnf install lnav [On Fedora 22+]</code>View two logs together:
<code>$ sudo lnav /var/log/apache2/access.log /var/log/apache2/error.log</code>4. less Command – Real‑time Output with Shift+F
Open a log with
lessand press
Shift+F(or start with
+F) to follow the file:
<code>sudo less +F /var/log/apache2/access.log</code>Further Reading
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.