Windows
Linux
Text Processing
Windows type (first lines) equivalent in Linux
Shows only the first N lines of a file — useful for quickly previewing large files.
Windows
→
type (first lines)
Linux equivalents
head
head
head
Overview
What this command does
Shows only the first N lines of a file — useful for quickly previewing large files.
Migration tip:
head -1 shows just the header row of a CSV. Combine with grep for powerful one-liners. head -n -5 means 'all lines except the last 5'.Practical tasks
Common use cases
Display the first lines of a file
Shows only the first N lines of a file — useful for quickly previewing large files.
head file.txt
First 10 lines (default)
head -n 20 file
First 20 lines
head -1 file.csv
First line only (CSV header)
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
head server.log
head -n 50 server.log
head -1 data.csv
head -n 5 *.log
Walkthrough
Examples with explanations
# No direct Windows CMD equivalent
head server.log # first 10 lines
head -n 50 server.log # first 50 lines
head -1 data.csv # just the header row
# Preview first 5 lines of every log:
head -n 5 *.log
Reference
Common options and variations
| Command or option | Use |
|---|---|
head file.txt | First 10 lines (default) |
head -n 20 file | First 20 lines |
head -1 file.csv | First line only (CSV header) |
head -c 100 file | First 100 bytes |
head -n -5 file | All lines except last 5 |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | head |
Same command on this distribution. |
| Fedora | same command | head |
Same command on this distribution. |
| Arch | same command | head |
Same command on this distribution. |
Keep learning