Beginner Package: coreutils

head

Show the first lines of a file.

Syntax

head [options] file

Description

head prints the beginning of a file (10 lines by default), which is useful for quickly checking a large file's format or the start of a log without opening the whole thing.

Examples

head file.txt
Show the first 10 lines
head -n 25 file.txt
Show a specific number of lines
head -c 200 file.txt
Show the first 200 bytes instead of lines

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux