Linux Survival Basics
Read-only, can be slowWatch Logs Without Opening the Whole File
You need to watch recent log lines while reproducing a service, script, or web request failure.
Command
tail -n 80 -f /var/log/nginx/error.log
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not leave noisy log tails running forever on a shared terminal. Be careful copying log output because it may contain URLs, tokens, usernames, or internal paths.
Expected output
Recent log lines followed by new lines as they are written.
System impact
Read-only, can be slow. Nothing changes. The command streams the end of the file so new failures are visible immediately.
May require elevated permissions on protected paths or service-owned files.
Scope this to the smallest useful path or service on busy systems.
When to use it
Use this while reproducing a web server, script, cron, or service failure so the new line appears as the failure happens.
When not to use it
Do not leave noisy log tails running forever on a shared terminal. Be careful copying log output because it may contain URLs, tokens, usernames, or internal paths.
Recovery / rollback
Press Ctrl-C to stop following the file.
next steps
Related commands
Find Errors Before Reading Every Log Line
The error was in the log. The problem was finding it without reading noise.
grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -40
Show Only Recent Errors
The log had old failures too. I only cared about the newest ones.
grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -10
Find the Exact Log Line Before You Scroll
The error was there. The useful part was knowing exactly where it was.
grep -inE 'error|failed|denied|timeout' /var/log/nginx/error.log
Read Current-Boot Logs for One Service
Ignore stale logs and inspect only what happened since this boot.
journalctl -u nginx -b --no-pager -n 80
Show Context Around the First App Error
The first error often explains more than the last one.
awk '{buf[NR%5]=$0} tolower($0) ~ /(error|exception|fatal)/ {for (i=NR-4;i<=NR;i++) if (i>0) print buf[i%5]; exit}' /var/log/app/app.log
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.