Small commands, big time savings when inspecting files. 16.11.2025 | reading time: 2 min Want to inspect files quickly from the shell? Use `head` to show the beginning and `tail` to show the end of files; both are lightweight, script-friendly tools that speed log checks and data sampling. Quick log peek Create a tiny log and run `head` and `tail` to see them in action; the output below shows both commands on the same file: ```bash $ printf '2025-11-16 INFO start 2025-11-16 WARN disk 2025-11-16 ERROR crash 2025-11-16 INFO retry 2025-11-16 INFO done ' > app.log $ head -n 3 app.log 2025-11-16 INFO start 2025-11-16 WARN disk 2025-11-16 ERROR crash $ tail -n 2 app.log 2025-11-16 INFO retry 2025-11-16 INFO done $ tail -f app.log # press Ctrl-C to stop ``` Flags that change behavior Remember the essentials: `-n` selects lines, `-c` selects bytes, `-f` follows appended data and `-F` follows name changes after rotation; use `tail -n +100 file` to start at line 100 and `tail --pid=1234 -f file` to stop following when a process exits. When to reach for which Use `head` to grab file headers or a quick sample, `tail -n` to inspect recent activity, and `tail -f` (or `tail -F`) to monitor live logs; combine with `grep`, `awk` or `sed` when extracting patterns or contextual lines for troubleshooting and automation. Try these next Pair `tail -f` with `less +F` for scrollback, pipe output into `awk` for field-aware summaries, or use `sed -n '100,110p'` as an alternative to `tail -n +100` when precise ranges are required; these mixes speed debugging and scripting. Finish line Mastering `head` and `tail` is a tiny, practical win that yields big daily savings; keep experimenting and consider structured learning — CompTIA Linux+ or LPIC-1 are logical next steps and bitsandbytes.academy offers intensive exam preparation to get there. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting filesystem