← All commands
Topic hub Text Processing
Windows Linux Text Processing Expanded guide

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
Debian/Ubuntu same command
head
Fedora same command
head
Arch same command
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.

Migration tip: <code>head -1</code> shows just the header row of a CSV. Combine with <code>grep</code> for powerful one-liners. <code>head -n -5</code> means 'all lines except the last 5'.

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.

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 optionUse
head file.txtFirst 10 lines (default)
head -n 20 fileFirst 20 lines
head -1 file.csvFirst line only (CSV header)
head -c 100 fileFirst 100 bytes
head -n -5 fileAll 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.

DistributionPackage manager / baseEquivalent commandDifference 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

Related Text Processing commands