head command
Show the first lines of a file.
- Text processing
- Package coreutils
- 4 options · 5 examples
Syntax
head [options] [file…]Provided by the coreutils package. Run man head for the full manual.
Common options
| Option | What it does |
|---|---|
-n N | Show the first N lines (default 10) |
-n -N | Show everything except the last N lines |
-c N | Show the first N bytes |
-q | Don't print file name headers |
Examples
First 10 lines
head file.txtFirst 20 lines
head -n 20 access.logAll but the last 5 lines
head -n -5 data.csvFirst 100 bytes
head -c 100 file.binTop 5 largest items in a directory
du -sh * | sort -rh | head -5
No example matches. Check the options table or search the guides.
head guides
- head Command in Linux with Examples Linux Commands · Updated Apr 2025
