Introduction
Sometimes you want to quickly see the beginning or the end of a file without opening the whole thing. The head and tail commands let you do just that by showing the first or last lines of a file.
When you want to check the first few lines of a log file to see its header or initial entries
When you want to see the last few lines of a log file to check recent events or errors
When you want to preview the start of a CSV file to understand its structure
When you want to monitor the end of a file that is actively growing, like a server log
When you want to extract a specific number of lines from the start or end of any text file