Utilities

Excellent Utilities: lnav – the log file navigator

Last Updated on May 22, 2022

In Operation

The main arguments to lnav are the files, directories, glob patterns, or URLs to be viewed. If no arguments are given, the default syslog file for your system is opened.

Here’s an image of lnav in operation.

lnav

The main part of the display shows the log lines from the files interleaved based on time-of-day. New lines are automatically loaded as they are appended to the files and, if you are viewing the bottom of the files, lnav scrolls down to show the new lines.

Errors and warnings are colored in red and yellow, respectively. Highlights are also applied to: SQL keywords, IP addresses, XML tags, file and line numbers in Java backtraces, and quoted strings.

Log file contents are merged into a single view based on message timestamps. This saves a lot of time when correlating timestamps across multiple windows.

One of the features that we frequently use is filtering. It lets you display only lines matching a specific pattern, filtering out the noise. Press colon and then, for example, enter filter-in gnome-shell to show only lines matching “gnome-shell”. Filters also apply to log lines as they are loaded.

lnav-filtering

An even more powerful feature is querying logs with SQL statements. This lets you perform queries on messages without loading the data into an SQL database. Instead, lnav using SQlite3’s virtual table feature. For all supported log file types, lnav creates tables that can be queried using the subset of SQL supported by Sqlite3. Environment variables can be used in SQL statements by prefixing the variable name with a dollar-sign. The query mode is accessed by pressing semicolon. SQL queries are checked for correctness as you type.

There’s also the ability to amalgamate data by time with the timeline view. This shows a histogram of messages over time. It’s accessed by pressing the i key. You can zoom in and out in this view.

lnav-histogram

Next page: Page 3 – Other Features

Pages in this article:
Page 1 – Introduction / Installation
Page 2 – In Operation
Page 3 – Other Features
Page 4 – Summary


Complete list of articles in this series:

Excellent Utilities
AES CryptEncrypt files using the Advanced Encryption Standard
AnanicyShell daemon created to manage processes’ IO and CPU priorities
brootNext gen tree explorer and customizable launcher
CerebroFast application launcher
cheat.shCommunity driven unified cheat sheet
CopyQAdvanced clipboard manager
crocSecurely transfer files and folders from the command-line
DeskreenLive streaming your desktop to a web browser
dufDisk usage utility with more polished presentation than the classic df
ezaA turbo-charged alternative to the venerable ls command
Extension ManagerBrowse, install and manage GNOME Shell Extensions
fdWonderful alternative to the venerable find
fkillKill processes quick and easy
fontpreviewQuickly search and preview fonts
horcruxFile splitter with encryption and redundancy
KoohaSimple screen recorder
KOReaderDocument viewer for a wide variety of file formats
ImagineA simple yet effective image optimization tool
LanguageToolStyle and grammar checker for 30+ languages
Liquid PromptAdaptive prompt for Bash & Zsh
lnavAdvanced log file viewer for the small-scale; great for troubleshooting
lsdLike exa, lsd is a turbo-charged alternative to ls
Mark TextSimple and elegant Markdown editor
McFlyNavigate through your bash shell history
mdlessFormatted and highlighted view of Markdown files
naviInteractive cheatsheet tool
notiMonitors a command or process and triggers a notification
NushellFlexible cross-platform shell with a modern feel
nvitopGPU process management for NVIDIA graphics cards
OCRmyPDFAdd OCR text layer to scanned PDFs
Oh My ZshFramework to manage your Zsh configuration
PaperworkDesigned to simplify the management of your paperwork
pastelGenerate, analyze, convert and manipulate colors
PDF Mix ToolPerform common editing operations on PDF files
pecoSimple interactive filtering tool that's remarkably useful
ripgrepRecursively search directories for a regex pattern
RnoteSketch and take handwritten notes
scrcpyDisplay and control Android devices
StickySimulates the traditional “sticky note” style stationery on your desktop
tldrSimplified and community-driven man pages
tmuxA terminal multiplexer that offers a massive boost to your workflow
TuskAn unofficial Evernote client with bags of potential
UlauncherSublime application launcher
WatsonTrack the time spent on projects
Whoogle SearchSelf-hosted and privacy-focused metasearch engine
ZellijTerminal workspace with batteries included
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Please read our Comment FAQ before posting a comment.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments