How to View the Start of a File in Linux (head)
head prints the first lines of a file, by default the first 10.
Published October 3, 2026
head prints the first lines of a file, by default the first 10.
Key points
- head -n 20 file.txt prints the first 20 lines instead of the default 10
- Useful for quickly previewing a large file, like a CSV export, without opening the whole thing
- The counterpart command, tail, does the same for the end of a file
Example
head -n 20 data.csv