Linux
linuxlinux-commandsReferenceBeginner
Output Beginning of Files (head)
Output the first part (first N lines or bytes) of files in Linux and Unix environments.
Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linuxmacos
#linux#head#files#text#cli
Command
head -n 10 filename.txt
Short Description
head prints the first part (by default, the first 10 lines) of one or more text files to standard output.
Examples
1. View First 10 Lines (Default)
head /etc/passwd2. View First 25 Lines (-n)
head -n 25 access.log3. View First 100 Bytes (-c)
head -c 100 binary_data.dat4. Combine with Pipeline
# View top 5 largest directories
du -sh * | sort -hr | head -n 5