How to Monitor Linux Logs in Real Time with Tail, Multitail, Lnav, and Less
This guide explains how to use Linux command‑line tools such as tail, tailf, tail ‑F, multitail, lnav, and less to continuously watch log files, covering installation, key options, and practical examples for single‑ and multi‑file monitoring.
1. tail Command – Monitor Logs in Real Time
The most common way to follow a growing log file is the tail command. It has two variants: tail -f /var/log/apache2/access.log follows the file using the -f flag. tailf /var/log/apache2/access.log is a built‑in version that implicitly includes -f.
When logs are rotated, use -F so that tail switches to the newly created file: sudo tail -F /var/log/apache2/access.log If you only need the last few lines while following, combine -n with -f:
sudo tail -n2 -f /var/log/apache2/access.log2. Multitail Command – Monitor Multiple Log Files in Real Time
Multitail can display several logs side by side and lets you scroll back through each file.
Installation commands:
$ sudo apt install multitail # Debian & Ubuntu
$ sudo yum install multitail # RedHat & CentOS
$ sudo dnf install multitail # Fedora 22+Example to watch both access and error logs simultaneously:
sudo multitail /var/log/apache2/access.log /var/log/apache2/error.log3. lnav Command – Monitor Multiple Log Files in Real Time
Lnav provides similar multi‑file monitoring with a built‑in viewer.
Install it with:
$ sudo apt install lnav # Debian & Ubuntu
$ sudo yum install lnav # RedHat & CentOS
$ sudo dnf install lnav # Fedora 22+To open two logs at once:
sudo lnav /var/log/apache2/access.log /var/log/apache2/error.log4. less Command – Display Real‑Time Output of Log Files
The less pager can also follow a file. Press Shift+F inside less, or start it with +F:
sudo less +F /var/log/apache2/access.logSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
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.
