Linux Survival Basics
Watch Logs Without Opening the Whole File
You need to watch recent log lines while a service or script is actively failing.
Command
tail -n 80 -f /var/log/nginx/error.log
What changed
Nothing changes. The command streams the end of the file so new failures are visible immediately.
Danger
safe
When to use it
Use this while reproducing a web server, script, cron, or service failure.
When not to use it
Do not leave noisy log tails running forever on a shared terminal.
Undo or recovery
Press Ctrl-C to stop following the file.
Expected output
Recent log lines followed by new lines as they are written.
demo script
Disposable terminal steps
tail -n 20 /var/log/nginx/error.logtail -n 80 -f /var/log/nginx/error.logprintf 'simulate a new error line\n' >> /var/log/nginx/error.log
simulated output
What it looks like
::fixture-ready::
$ tail -n 20 /var/log/nginx/error.log
2026/06/25 10:00:01 [notice] 11#11: start worker process
2026/06/25 10:01:42 [error] 11#11: *7 connect() failed (111: Connection refused) while connecting to upstream
2026/06/25 10:02:05 [warn] 11#11: upstream server temporarily disabled
2026/06/25 10:03:16 [error] 11#11: *9 access forbidden by rule, client: 203.0.113.44
2026/06/25 10:04:33 [error] 11#11: *10 upstream timed out while reading response header
::exit-code::0
$ tail -n 80 -f /var/log/nginx/error.log
2026/06/25 10:00:01 [notice] 11#11: start worker process
2026/06/25 10:01:42 [error] 11#11: *7 connect() failed (111: Connection refused) while connecting to upstream
2026/06/25 10:02:05 [warn] 11#11: upstream server temporarily disabled
2026/06/25 10:03:16 [error] 11#11: *9 access forbidden by rule, client: 203.0.113.44
2026/06/25 10:04:33 [error] 11#11: *10 upstream timed out while reading response header
::exit-code::124
$ printf 'simulate a new error line\n' >> /var/log/nginx/error.log
::exit-code::0
YouTube Short
Watch the failure happen live.
Do not open the whole log file. Tail the last useful lines, reproduce the issue, and watch the error arrive.
LinkedIn hook
The app was failing now. Opening a giant log file was the wrong move.
Question: Do you inspect logs before or after reproducing a bug?
experiments
A/B tests to run
Metric: youtube_retention_15s
A: Watch the failure happen live.
B: Stop opening giant log files.