head

Output the first N lines of a file.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

head outputs the first 10 lines by default (or N lines with -n). Essential for quickly previewing large files without loading them entirely. Also useful for extracting file headers in scripts.

Common flags
FlagMeaning
-n --linesOutput the first N lines
-c --bytesOutput the first N bytes
Examples
head -n 20 /var/log/syslogView first 20 lines of syslog · explain & risk-check →
head -1 data.csvCheck CSV header row · explain & risk-check →
ls -lt | head -5Show 5 most recently modified files · explain & risk-check →
Pro tip

Use `head -n -5 file.txt` (negative N) to print everything except the last 5 lines — a lesser-known but powerful trick.

Related
tail less cat
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man head for your version. Test destructive commands on a non-production system first.