Windows type (first lines) equivalent in Linux
Shows only the first N lines of a file — useful for quickly previewing large files.
type (first lines)
head
head
head
Overview
What this command does
On Windows, "type (first lines)" is used to display the first lines of a file. On Linux, the closest practical mapping shown here is "head". Shows only the first N lines of a file — useful for quickly previewing large files. This reference is grouped under Text Processing.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows type (first lines) maps to head for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read Linux command-line basics.
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
Debian/Ubuntu, Fedora and Arch all use "head" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| 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