Beginner's Must-Know: Linux Log File Viewing Commands
This article introduces the five log-viewing commands every Linux server beginner must learn, for daily troubleshooting and monitoring. Core commands and uses: 1. tail: view the end of a file, commonly with -n number to specify lines, -f for real-time monitoring (e.g. web access logs), and -q to hide filenames. 2. head: view the beginning of a file with -n number to specify lines, suitable for initial logs (e.g. system boot logs). 3. cat: quickly view the full contents of small files, with -n/-b to show line numbers; not recommended for large files (screen flooding). 4. less: page through large files, supporting up/down paging and search (/keyword), with +G jumping to the end. 5. grep: filter by keyword, with -n to show line numbers, -i to ignore case, -v for inverse filtering, often combined with tail (e.g. tail -f log | grep error). Combined tips: tail -n 100 log | grep error quickly locates errors, and less +G log jumps to the end of the log.
Read More