Operations 12 min read

Master Quick Log Analysis: Powerful Linux Commands to Pinpoint Errors Fast

This guide shows how to efficiently locate errors in massive server logs using Linux commands like tail, cat, grep, sed, and navigation shortcuts, providing step‑by‑step techniques for dynamic viewing, time‑range searches, keyword filtering, and paginated inspection.

Open Source Linux
Open Source Linux
Open Source Linux
Master Quick Log Analysis: Powerful Linux Commands to Pinpoint Errors Fast

Today we discuss how to quickly locate errors in massive log files.

Fast error pinpointing in large logs

Dynamic log viewing tail -f catalina.out Open log file from the beginning cat catalina.out Redirect a new log to a file for inspection >nanjiangtest.txt Example of grepping a specific line number and saving

# cat -n catalina.out | grep 717892466 >nanjiangtest.txt

Simple tail/head commands

# tail -n number catalina.out   # show last number lines
# tail -n +number catalina.out  # show from line number onward
# head -n number catalina.out   # show first number lines
# head -n -number catalina.out # show all but last number lines

Method 1: Find line numbers by keyword

Use grep to get few lines, then locate surrounding logs. # cat -n test.log | grep "keyword" Combine tail and head to view context

# cat -n catalina.out | tail -n +13230539 | head -n 10

Method 2: Search logs within a time range

grep '11:07 18:29:20' catalina.out
grep '11:07 18:31:11' catalina.out
sed -n '/11:07 18:29:20/,/11:07 18:31:11/p' catalina.out
sed -n '/11:07 18:29:/,/11:07 18:31:/p' catalina.out

Method 3: Count occurrences of a specific string

grep '1175109632' catalina.out | wc -l

Method 4: Get last number lines and filter keyword

# tail -n 20 catalina.out | grep 'INFO Takes:1'

Method 5: Same as above with colored output

# tail -n 20 catalina.out | grep 'INFO Takes:1' --color

Method 6: Show two lines of context around matches

# tail -n 20 catalina.out | grep 'INFO Takes:1' --color -a2

Method 7: Paginated view using more/less

# tail -n 2000 catalina.out | grep 'INFO Takes:1' --color -a2 | more
# tail -n 2000 catalina.out | grep 'INFO Takes:1' --color -a2 | less

Additional navigation shortcuts

Full-screen navigation

ctrl + F

– move forward one screen ctrl + B – move backward one screen ctrl + D – move forward half screen ctrl + U – move backward half screen

Single-line navigation

j

– move forward one line k – move backward one line

Other navigation

G

– go to last line g – go to first line q / ZZ – quit less

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxcommand-linelog analysisGreptailserver troubleshooting
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.