head
Output the first part of files — default is the first 10 lines.
Synopsis
head [OPTION]... [FILE]...
Examples
head file.txt
head -n 5 file.txt
head -c 100 binary.dat
head -n 1 *.csv
Common options
| Flag | Description |
|---|---|
| -n | Print first N lines |
| -c | Print first N bytes |
| -q | Never print filename headers |
| -v | Always print filename headers |
About head
The `head` command output the first part of files — default is the first 10 lines. Text viewing and editing commands are fundamental tools in any Linux user's toolkit.
Linux treats almost everything as a file, so the ability to quickly inspect, filter, transform, and edit file contents from the command line is critical. These commands are regularly combined with pipes and redirects to build powerful data-processing pipelines.
The command accepts 4 commonly used flags shown above, though the full set of options is available in the man page (`man head`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More File Viewing & Editing Commands
Other commands in the File Viewing & Editing category