Master Real-Time Log Monitoring on Linux with tail, multitail, lnav & less
This guide explains how to use Linux commands such as tail, tailf, tail -F, multitail, lnav, and less to monitor log files in real time, covering installation, key options, and practical examples for single and multiple log streams.
1. tail Command – Monitor Logs in Real Time
The tail utility is the most common way to watch a growing log file. Use the -f flag to follow a file: $ sudo tail -f /var/log/apache2/access.log The built‑in tailf command behaves the same way without needing -f: $ sudo tailf /var/log/apache2/access.log When logs are rotated, use -F so tail follows the new file descriptor: $ sudo tail -F /var/log/apache2/access.log To display only the last two lines while following, combine -n and -f:
$ sudo tail -n2 -f /var/log/apache2/access.log2. Multitail Command – Watch Multiple Logs Simultaneously
Multitail can monitor several log files at once and lets you scroll back within each stream.
Installation:
$ sudo apt install multitail # Debian/Ubuntu
$ sudo yum install multitail # RedHat/CentOS
$ sudo dnf install multitail # Fedora 22+Example – display both access and error logs together:
$ sudo multitail /var/log/apache2/access.log /var/log/apache2/error.log3. lnav Command – Another Multi‑Log Viewer
lnav offers similar multi‑file monitoring with a richer interactive interface.
Installation:
$ sudo apt install lnav # Debian/Ubuntu
$ sudo yum install lnav # RedHat/CentOS
$ sudo dnf install lnav # Fedora 22+Run lnav on two logs:
$ sudo lnav /var/log/apache2/access.log /var/log/apache2/error.log4. less Command – Real‑Time View with Shift+F
The classic pager less can also follow a file. Press Shift+F after opening, or start it with +F: $ sudo less +F /var/log/apache2/access.log Like tail, less will keep displaying new lines as the file grows.
Signed-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
